mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-23 21:39:55 +00:00
Expand this to allow for multiple blocks for the same component.
This commit is contained in:
1 parent
b6400fca87
commit
fd38fb1d55
2 files changed
+49
-13
No files matched your search
@@ -9,8 +9,8 @@ import cpw.mods.fml.common.registry.GameData;
|
||||
*/
|
||||
public class BlockStack {
|
||||
|
||||
private Block block;
|
||||
private int meta;
|
||||
private final Block block;
|
||||
private final int meta;
|
||||
|
||||
public BlockStack(Block block, int meta) {
|
||||
this.block = block;
|
||||
|
||||
+47
-11
@@ -1,23 +1,37 @@
|
||||
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.BlockStack;
|
||||
|
||||
public class AltarComponent {
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private Block block;
|
||||
private int metadata;
|
||||
private boolean isBloodRune;
|
||||
private boolean isUpgradeSlot;
|
||||
private final int x, y, z;
|
||||
private final List<BlockStack> validBlocks;
|
||||
|
||||
private final boolean isBloodRune, isUpgradeSlot;
|
||||
|
||||
public AltarComponent(int x, int y, int z, Block block, int metadata, boolean isBloodRune, boolean isUpgradeSlot) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.block = block;
|
||||
this.metadata = metadata;
|
||||
this.validBlocks = new ArrayList<>();
|
||||
this.validBlocks.add(new BlockStack(block, metadata));
|
||||
this.isBloodRune = isBloodRune;
|
||||
this.isUpgradeSlot = isUpgradeSlot;
|
||||
}
|
||||
|
||||
public AltarComponent(int x, int y, int z, List<BlockStack> validBlocks, boolean isBloodRune,
|
||||
boolean isUpgradeSlot) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.validBlocks = validBlocks;
|
||||
this.isBloodRune = isBloodRune;
|
||||
this.isUpgradeSlot = isUpgradeSlot;
|
||||
}
|
||||
@@ -35,11 +49,17 @@ public class AltarComponent {
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
if (validBlocks.isEmpty()) {
|
||||
return Blocks.air;
|
||||
}
|
||||
return validBlocks.get(0).getBlock();
|
||||
}
|
||||
|
||||
public int getMetadata() {
|
||||
return metadata;
|
||||
if (validBlocks.isEmpty()) {
|
||||
return OreDictionary.WILDCARD_VALUE;
|
||||
}
|
||||
return validBlocks.get(0).getMeta();
|
||||
}
|
||||
|
||||
public boolean isBloodRune() {
|
||||
@@ -49,4 +69,20 @@ public class AltarComponent {
|
||||
public boolean isUpgradeSlot() {
|
||||
return isUpgradeSlot;
|
||||
}
|
||||
|
||||
public List<BlockStack> getValidBlocks() {
|
||||
return validBlocks;
|
||||
}
|
||||
|
||||
public boolean matches(Block block, int meta) {
|
||||
if (validBlocks.isEmpty()) return true;
|
||||
|
||||
for (BlockStack pair : validBlocks) {
|
||||
if (pair.getBlock() == block
|
||||
&& (pair.getMeta() == meta || pair.getMeta() == OreDictionary.WILDCARD_VALUE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user