IC2 fixes

This commit is contained in:
Raoul Van den Berge
2016-07-04 20:00:11 +02:00
parent bf6766fb83
commit 508a5bfdfd
3 changed files with 22 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ public class SlotGridCraftingResult extends SlotCrafting {
onCrafting(stack); onCrafting(stack);
if (!player.worldObj.isRemote) { if (!player.worldObj.isRemote) {
grid.onCrafted(); grid.onCrafted(container);
container.sendCraftingSlots(); container.sendCraftingSlots();
} }

View File

@@ -22,6 +22,7 @@ import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fml.common.Optional;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageBlocks; import refinedstorage.RefinedStorageBlocks;
import refinedstorage.tile.controller.TileController; import refinedstorage.tile.controller.TileController;
@@ -33,6 +34,10 @@ import java.util.List;
import static refinedstorage.RefinedStorageUtils.convertIC2ToRF; import static refinedstorage.RefinedStorageUtils.convertIC2ToRF;
import static refinedstorage.RefinedStorageUtils.convertRFToIC2; import static refinedstorage.RefinedStorageUtils.convertRFToIC2;
@Optional.InterfaceList({
@Optional.Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2"),
@Optional.Interface(iface = "ic2.api.item.IElectricItemManager", modid = "IC2")
})
public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialElectricItem, IElectricItemManager { public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialElectricItem, IElectricItemManager {
public static final int TYPE_NORMAL = 0; public static final int TYPE_NORMAL = 0;
public static final int TYPE_CREATIVE = 1; public static final int TYPE_CREATIVE = 1;
@@ -225,51 +230,61 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
return getUnlocalizedName() + "." + stack.getItemDamage(); return getUnlocalizedName() + "." + stack.getItemDamage();
} }
@Optional.Method(modid = "IC2")
@Override @Override
public IElectricItemManager getManager(ItemStack stack) { public IElectricItemManager getManager(ItemStack stack) {
return this; return this;
} }
@Optional.Method(modid = "IC2")
@Override @Override
public double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) { public double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
return convertRFToIC2(receiveEnergy(stack, convertIC2ToRF(amount), simulate)); return convertRFToIC2(receiveEnergy(stack, convertIC2ToRF(amount), simulate));
} }
@Optional.Method(modid = "IC2")
@Override @Override
public double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate) { public double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate) {
return convertRFToIC2(extractEnergy(stack, convertIC2ToRF(amount), simulate)); return convertRFToIC2(extractEnergy(stack, convertIC2ToRF(amount), simulate));
} }
@Optional.Method(modid = "IC2")
@Override @Override
public double getCharge(ItemStack stack) { public double getCharge(ItemStack stack) {
return convertRFToIC2(getEnergyStored(stack)); return convertRFToIC2(getEnergyStored(stack));
} }
@Optional.Method(modid = "IC2")
@Override @Override
public double getMaxCharge(ItemStack stack) { public double getMaxCharge(ItemStack stack) {
return convertRFToIC2(getMaxEnergyStored(stack)); return convertRFToIC2(getMaxEnergyStored(stack));
} }
@Optional.Method(modid = "IC2")
@Override @Override
public boolean canUse(ItemStack stack, double amount) { public boolean canUse(ItemStack stack, double amount) {
return true; return true;
} }
@Optional.Method(modid = "IC2")
@Override @Override
public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { public boolean use(ItemStack stack, double amount, EntityLivingBase entity) {
return true; return true;
} }
@Optional.Method(modid = "IC2")
@Override @Override
public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) {
// NO OP // NO OP
} }
@Optional.Method(modid = "IC2")
@Override @Override
public String getToolTip(ItemStack stack) { public String getToolTip(ItemStack stack) {
return null; return null;
} }
@Optional.Method(modid = "IC2")
@Override @Override
public int getTier(ItemStack stack) { public int getTier(ItemStack stack) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;

View File

@@ -126,7 +126,7 @@ public class TileGrid extends TileNode implements IGrid {
result.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(matrix, worldObj)); result.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(matrix, worldObj));
} }
public void onCrafted() { public void onCrafted(ContainerGrid container) {
ItemStack[] remainder = CraftingManager.getInstance().getRemainingItems(matrix, worldObj); ItemStack[] remainder = CraftingManager.getInstance().getRemainingItems(matrix, worldObj);
for (int i = 0; i < matrix.getSizeInventory(); ++i) { for (int i = 0; i < matrix.getSizeInventory(); ++i) {
@@ -146,6 +146,10 @@ public class TileGrid extends TileNode implements IGrid {
} }
onCraftingMatrixChanged(); onCraftingMatrixChanged();
if (container != null) {
container.sendCraftingSlots();
}
} }
public void onCraftedShift(ContainerGrid container, EntityPlayer player) { public void onCraftedShift(ContainerGrid container, EntityPlayer player) {
@@ -154,7 +158,7 @@ public class TileGrid extends TileNode implements IGrid {
ItemStack crafted = result.getStackInSlot(0); ItemStack crafted = result.getStackInSlot(0);
while (true) { while (true) {
onCrafted(); onCrafted(null);
craftedItemsList.add(crafted.copy()); craftedItemsList.add(crafted.copy());