mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 15:33:06 +00:00
Remove AT and fix hardcoded check for vanilla anvil
This commit is contained in:
1 parent
8aa7bc3309
commit
75d384ec28
2 files changed
+34
-19
No files matched your search
@@ -1,28 +1,46 @@
|
||||
package crazypants.enderio.block;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.ContainerRepair;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
|
||||
public class ContainerDarkSteelAnvil extends ContainerRepair {
|
||||
|
||||
private int x, y, z;
|
||||
|
||||
|
||||
private final Field _outputSlot = ReflectionHelper.findField(ContainerRepair.class, "outputSlot", "field_82852_f");
|
||||
private final Field _inputSlots = ReflectionHelper.findField(ContainerRepair.class, "inputSlots", "field_82853_g");
|
||||
private final Field _materialCost = ReflectionHelper.findField(ContainerRepair.class, "materialCost", "stackSizeToBeUsedInRepair", "field_82856_l");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ContainerDarkSteelAnvil(InventoryPlayer playerInv, final World world, final int x, final int y, final int z, EntityPlayer player) {
|
||||
super(playerInv, world, x, y, z, player);
|
||||
|
||||
final IInventory outputSlot, inputSlots;
|
||||
final int materialCost;
|
||||
|
||||
try {
|
||||
outputSlot = (IInventory) _outputSlot.get(this);
|
||||
inputSlots = (IInventory) _inputSlots.get(this);
|
||||
materialCost = _materialCost.getInt(this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
this.inventorySlots.set(2, new Slot(this.outputSlot, 2, 134, 47) {
|
||||
|
||||
this.inventorySlots.set(2, new Slot(outputSlot, 2, 134, 47) {
|
||||
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return false;
|
||||
@@ -38,24 +56,24 @@ public class ContainerDarkSteelAnvil extends ContainerRepair {
|
||||
player.addExperienceLevel(-ContainerDarkSteelAnvil.this.maximumCost);
|
||||
}
|
||||
|
||||
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(0, (ItemStack) null);
|
||||
inputSlots.setInventorySlotContents(0, (ItemStack) null);
|
||||
|
||||
if(ContainerDarkSteelAnvil.this.stackSizeToBeUsedInRepair > 0) {
|
||||
ItemStack itemstack1 = ContainerDarkSteelAnvil.this.inputSlots.getStackInSlot(1);
|
||||
if(materialCost > 0) {
|
||||
ItemStack itemstack1 = inputSlots.getStackInSlot(1);
|
||||
|
||||
if(itemstack1 != null && itemstack1.stackSize > ContainerDarkSteelAnvil.this.stackSizeToBeUsedInRepair) {
|
||||
itemstack1.stackSize -= ContainerDarkSteelAnvil.this.stackSizeToBeUsedInRepair;
|
||||
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(1, itemstack1);
|
||||
if(itemstack1 != null && itemstack1.stackSize > materialCost) {
|
||||
itemstack1.stackSize -= materialCost;
|
||||
inputSlots.setInventorySlotContents(1, itemstack1);
|
||||
} else {
|
||||
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
}
|
||||
} else {
|
||||
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
}
|
||||
|
||||
ContainerDarkSteelAnvil.this.maximumCost = 0;
|
||||
|
||||
if(!player.capabilities.isCreativeMode && !world.isRemote && world.getBlock(x, y, z) == Blocks.anvil
|
||||
if(!player.capabilities.isCreativeMode && !world.isRemote && world.getBlock(x, y, z) == EnderIO.blockDarkSteelAnvil
|
||||
&& player.getRNG().nextFloat() < Config.darkSteelAnvilDamageChance) {
|
||||
int i1 = world.getBlockMetadata(x, y, z);
|
||||
int k = i1 & 3;
|
||||
@@ -75,7 +93,7 @@ public class ContainerDarkSteelAnvil extends ContainerRepair {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return player.worldObj.getBlock(this.x, this.y, this.z) == EnderIO.blockDarkSteelAnvil;
|
||||
|
||||
Reference in new issue
Block a user