A few bug fixes
This commit is contained in:
parent
b89349894e
commit
7d69639a8a
6 changed files with 65 additions and 52 deletions
|
@ -1,6 +1,7 @@
|
|||
package mekanism.common;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.multipart.TransmitterType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
|
@ -86,4 +87,26 @@ public final class Tier
|
|||
guiLocation = gui;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The tiers used by Universal Cables and their corresponding values.
|
||||
* @author aidancbrady
|
||||
*
|
||||
*/
|
||||
public static enum CableTier
|
||||
{
|
||||
BASIC(500, TransmitterType.UNIVERSAL_CABLE_BASIC),
|
||||
ADVANCED(2000, TransmitterType.UNIVERSAL_CABLE_ADVANCED),
|
||||
ELITE(8000, TransmitterType.UNIVERSAL_CABLE_ELITE),
|
||||
ULTIMATE(32000, TransmitterType.UNIVERSAL_CABLE_ULTIMATE);
|
||||
|
||||
public int cableCapacity;
|
||||
public TransmitterType type;
|
||||
|
||||
private CableTier(int capacity, TransmitterType transmitterType)
|
||||
{
|
||||
cableCapacity = capacity;
|
||||
type = transmitterType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,20 +9,24 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.common.block.BlockCardboardBox.BlockData;
|
||||
import mekanism.common.tile.TileEntityCardboardBox;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockCardboardBox extends ItemBlock
|
||||
{
|
||||
private static boolean isMonitoring;
|
||||
|
||||
public Block metaBlock;
|
||||
|
||||
public ItemBlockCardboardBox(int id, Block block)
|
||||
|
@ -30,6 +34,8 @@ public class ItemBlockCardboardBox extends ItemBlock
|
|||
super(id);
|
||||
setMaxStackSize(1);
|
||||
metaBlock = block;
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +82,8 @@ public class ItemBlockCardboardBox extends ItemBlock
|
|||
data.id = id;
|
||||
data.meta = meta;
|
||||
|
||||
isMonitoring = true;
|
||||
|
||||
if(world.getBlockTileEntity(x, y, z) != null)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
@ -83,21 +91,6 @@ public class ItemBlockCardboardBox extends ItemBlock
|
|||
|
||||
tile.writeToNBT(tag);
|
||||
data.tileTag = tag;
|
||||
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
IInventory inv = (IInventory)tile;
|
||||
|
||||
for(int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
inv.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
if(tile instanceof IDeepStorageUnit)
|
||||
{
|
||||
((IDeepStorageUnit)tile).setStoredItemCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
|
@ -107,6 +100,8 @@ public class ItemBlockCardboardBox extends ItemBlock
|
|||
|
||||
world.setBlock(x, y, z, Mekanism.cardboardBoxID, 1, 3);
|
||||
|
||||
isMonitoring = false;
|
||||
|
||||
TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(tileEntity != null)
|
||||
|
@ -163,4 +158,13 @@ public class ItemBlockCardboardBox extends ItemBlock
|
|||
|
||||
return BlockData.read(itemstack.stackTagCompound.getCompoundTag("blockData"));
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onEntitySpawn(EntityJoinWorldEvent event)
|
||||
{
|
||||
if(event.entity instanceof EntityItem && isMonitoring)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ import mekanism.api.transmitters.IGridTransmitter;
|
|||
import mekanism.api.transmitters.ITransmitterNetwork;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.multipart.PartUniversalCable.CableTier;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.CableTier;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -85,9 +86,9 @@ public class ItemPartTransmitter extends JItemMultiPart
|
|||
{
|
||||
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
if(itemstack.getItemDamage() < CableTier.values().length)
|
||||
if(itemstack.getItemDamage() < Tier.CableTier.values().length)
|
||||
{
|
||||
list.add(EnumColor.INDIGO + "Capacity: " + EnumColor.GREY + CableTier.values()[itemstack.getItemDamage()].cableCapacity + "J/t");
|
||||
list.add(EnumColor.INDIGO + "Capacity: " + EnumColor.GREY + Tier.CableTier.values()[itemstack.getItemDamage()].cableCapacity + "J/t");
|
||||
}
|
||||
|
||||
list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for details.");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mekanism.common.multipart;
|
||||
|
||||
import mekanism.common.multipart.PartUniversalCable.CableTier;
|
||||
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.CableTier;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.MultipartGenerator;
|
||||
|
@ -40,23 +40,23 @@ public class MultipartMekanism implements IPartFactory
|
|||
{
|
||||
if(name.equals("mekanism:universal_cable"))
|
||||
{
|
||||
return new PartUniversalCable(CableTier.BASIC);
|
||||
return new PartUniversalCable(Tier.CableTier.BASIC);
|
||||
}
|
||||
else if(name.equals("mekanism:universal_cable_basic"))
|
||||
{
|
||||
return new PartUniversalCable(CableTier.BASIC);
|
||||
return new PartUniversalCable(Tier.CableTier.BASIC);
|
||||
}
|
||||
else if(name.equals("mekanism:universal_cable_advanced"))
|
||||
{
|
||||
return new PartUniversalCable(CableTier.ADVANCED);
|
||||
return new PartUniversalCable(Tier.CableTier.ADVANCED);
|
||||
}
|
||||
else if(name.equals("mekanism:universal_cable_elite"))
|
||||
{
|
||||
return new PartUniversalCable(CableTier.ELITE);
|
||||
return new PartUniversalCable(Tier.CableTier.ELITE);
|
||||
}
|
||||
else if(name.equals("mekanism:universal_cable_ultimate"))
|
||||
{
|
||||
return new PartUniversalCable(CableTier.ULTIMATE);
|
||||
return new PartUniversalCable(Tier.CableTier.ULTIMATE);
|
||||
}
|
||||
else if(name.equals("mekanism:mechanical_pipe"))
|
||||
{
|
||||
|
|
|
@ -18,8 +18,9 @@ import mekanism.client.render.RenderPartTransmitter;
|
|||
import mekanism.common.IConfigurable;
|
||||
import mekanism.common.ITileNetwork;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.CableTier;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.multipart.PartUniversalCable.CableTier;
|
||||
import mekanism.common.multipart.TransmitterType.Size;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -97,13 +98,13 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
switch(type)
|
||||
{
|
||||
case UNIVERSAL_CABLE_BASIC:
|
||||
return new PartUniversalCable(CableTier.BASIC);
|
||||
return new PartUniversalCable(Tier.CableTier.BASIC);
|
||||
case UNIVERSAL_CABLE_ADVANCED:
|
||||
return new PartUniversalCable(CableTier.ADVANCED);
|
||||
return new PartUniversalCable(Tier.CableTier.ADVANCED);
|
||||
case UNIVERSAL_CABLE_ELITE:
|
||||
return new PartUniversalCable(CableTier.ELITE);
|
||||
return new PartUniversalCable(Tier.CableTier.ELITE);
|
||||
case UNIVERSAL_CABLE_ULTIMATE:
|
||||
return new PartUniversalCable(CableTier.ULTIMATE);
|
||||
return new PartUniversalCable(Tier.CableTier.ULTIMATE);
|
||||
case MECHANICAL_PIPE:
|
||||
return new PartMechanicalPipe();
|
||||
case PRESSURIZED_TUBE:
|
||||
|
|
|
@ -14,6 +14,7 @@ import mekanism.api.transmitters.TransmissionType;
|
|||
import mekanism.client.render.RenderPartTransmitter;
|
||||
import mekanism.common.EnergyNetwork;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
|
@ -33,7 +34,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implements IStrictEnergyAcceptor, IEnergySink, IEnergyHandler, IPowerReceptor
|
||||
{
|
||||
public CableTier tier;
|
||||
public Tier.CableTier tier;
|
||||
|
||||
/** A fake power handler used to initiate energy transfer calculations. */
|
||||
public PowerHandler powerHandler;
|
||||
|
@ -45,7 +46,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
|||
public double cacheEnergy = 0;
|
||||
public double lastWrite = 0;
|
||||
|
||||
public PartUniversalCable(CableTier cableTier)
|
||||
public PartUniversalCable(Tier.CableTier cableTier)
|
||||
{
|
||||
tier = cableTier;
|
||||
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
|
||||
|
@ -96,7 +97,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
|||
super.load(nbtTags);
|
||||
|
||||
cacheEnergy = nbtTags.getDouble("cacheEnergy");
|
||||
tier = CableTier.values()[nbtTags.getInteger("tier")];
|
||||
tier = Tier.CableTier.values()[nbtTags.getInteger("tier")];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -396,21 +397,4 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
|||
reconfigure();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum CableTier
|
||||
{
|
||||
BASIC(500, TransmitterType.UNIVERSAL_CABLE_BASIC),
|
||||
ADVANCED(2000, TransmitterType.UNIVERSAL_CABLE_ADVANCED),
|
||||
ELITE(8000, TransmitterType.UNIVERSAL_CABLE_ELITE),
|
||||
ULTIMATE(32000, TransmitterType.UNIVERSAL_CABLE_ULTIMATE);
|
||||
|
||||
int cableCapacity;
|
||||
TransmitterType type;
|
||||
|
||||
private CableTier(int capacity, TransmitterType transmitterType)
|
||||
{
|
||||
cableCapacity = capacity;
|
||||
type = transmitterType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue