mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-28 02:48:14 -05:00
Update #48 - Added some features from OptiFine
This commit is contained in:
61
sources/main/java/net/optifine/config/MatchBlock.java
Normal file
61
sources/main/java/net/optifine/config/MatchBlock.java
Normal file
@ -0,0 +1,61 @@
|
||||
package net.optifine.config;
|
||||
|
||||
import net.minecraft.block.state.BlockStateBase;
|
||||
import net.optifine.Config;
|
||||
|
||||
public class MatchBlock {
|
||||
private int blockId = -1;
|
||||
private int[] metadatas = null;
|
||||
|
||||
public MatchBlock(int blockId) {
|
||||
this.blockId = blockId;
|
||||
}
|
||||
|
||||
public MatchBlock(int blockId, int metadata) {
|
||||
this.blockId = blockId;
|
||||
|
||||
if (metadata >= 0 && metadata <= 15) {
|
||||
this.metadatas = new int[] { metadata };
|
||||
}
|
||||
}
|
||||
|
||||
public MatchBlock(int blockId, int[] metadatas) {
|
||||
this.blockId = blockId;
|
||||
this.metadatas = metadatas;
|
||||
}
|
||||
|
||||
public int getBlockId() {
|
||||
return this.blockId;
|
||||
}
|
||||
|
||||
public int[] getMetadatas() {
|
||||
return this.metadatas;
|
||||
}
|
||||
|
||||
public boolean matches(BlockStateBase blockState) {
|
||||
return blockState.getBlockId() != this.blockId ? false
|
||||
: Matches.metadata(blockState.getMetadata(), this.metadatas);
|
||||
}
|
||||
|
||||
public boolean matches(int id, int metadata) {
|
||||
return id != this.blockId ? false : Matches.metadata(metadata, this.metadatas);
|
||||
}
|
||||
|
||||
public void addMetadata(int metadata) {
|
||||
if (this.metadatas != null) {
|
||||
if (metadata >= 0 && metadata <= 15) {
|
||||
for (int i = 0; i < this.metadatas.length; ++i) {
|
||||
if (this.metadatas[i] == metadata) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.metadatas = Config.addIntToArray(this.metadatas, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + this.blockId + ":" + Config.arrayToString(this.metadatas);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user