Added ability to toggle wire ticking via shift-right-click

This commit is contained in:
Calclavia 2013-08-23 21:31:05 +08:00
parent 2701b2b39c
commit 8cee88502b
9 changed files with 64 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

View file

@ -7,7 +7,6 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import resonantinduction.battery.BatteryManager.SlotBattery;
import resonantinduction.battery.BatteryManager.SlotOut;
import universalelectricity.core.item.IItemElectric;
import calclavia.lib.gui.ContainerBase;
public class ContainerBattery extends ContainerBase

View file

@ -3,9 +3,7 @@
*/
package resonantinduction.battery;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.Configuration;
import resonantinduction.ResonantInduction;
import resonantinduction.TabRI;

View file

@ -3,23 +3,13 @@
*/
package resonantinduction.render;
import java.net.URL;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.client.model.IModelCustomLoader;
import net.minecraftforge.client.model.ModelFormatException;
import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction;
import resonantinduction.battery.BlockBattery;
import resonantinduction.battery.TileEntityBattery;
import resonantinduction.contractor.BlockEMContractor;
import resonantinduction.multimeter.BlockMultimeter;
import resonantinduction.tesla.BlockTesla;

View file

@ -18,8 +18,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;

View file

@ -11,14 +11,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.block.BlockFurnace;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

View file

@ -1,5 +1,6 @@
package resonantinduction.wire;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
@ -8,10 +9,12 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.ResonantInduction;
import resonantinduction.TabRI;
import universalelectricity.core.block.IConductor;
import universalelectricity.prefab.block.BlockConductor;
/**
@ -50,6 +53,32 @@ public class BlockWire extends BlockConductor
}
}
if (!world.isRemote)
{
if (entityPlayer.isSneaking())
{
/**
* Change the TileEntity type.
*/
NBTTagCompound nbt = new NBTTagCompound();
tileEntity.writeToNBT(nbt);
if (tileEntity instanceof TileEntityTickWire)
{
nbt.setString("id", this.getUnlocalizedName());
entityPlayer.addChatMessage("Wire will now stop ticking and withdrawing energy.");
}
else
{
nbt.setString("id", this.getUnlocalizedName() + "2");
entityPlayer.addChatMessage("Wire will now tick and withdraw energy.");
}
world.setBlockTileEntity(x, y, z, TileEntity.createAndLoadEntity(nbt));
((IConductor) world.getBlockTileEntity(x, y, z)).refresh();
}
}
return false;
}
@ -86,7 +115,7 @@ public class BlockWire extends BlockConductor
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityTickWire();
return new TileEntityWire();
}
@Override
@ -104,4 +133,36 @@ public class BlockWire extends BlockConductor
}
}
/**
* This returns a complete list of items dropped from this block.
*
* @param world The current world
* @param x X Position
* @param y Y Position
* @param z Z Position
* @param metadata Current metadata
* @param fortune Breakers fortune level
* @return A ArrayList containing all items this block drops
*/
@Override
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
{
ArrayList<ItemStack> ret = super.getBlockDropped(world, x, y, z, metadata, fortune);
TileEntity t = world.getBlockTileEntity(x, y, z);
/**
* Drop wool insulation if the wire is insulated.
*/
if (t instanceof TileEntityWire)
{
TileEntityWire tileEntity = (TileEntityWire) t;
if (tileEntity.isInsulated)
{
ret.add(new ItemStack(Block.cloth));
}
}
return ret;
}
}

View file

@ -12,8 +12,7 @@ import universalelectricity.core.vector.Vector3;
public enum EnumWireMaterial
{
COPPER(12.5f, 3, 2, new Vector3(132, 73, 33)),
TIN(10, 2, 0.5f, new Vector3(215, 205, 181)),
COPPER(12.5f, 3, 2, new Vector3(132, 73, 33)), TIN(10, 2, 0.5f, new Vector3(215, 205, 181)),
IRON(0.1f, 2, 4, new Vector3(97, 102, 105)),
ALUMINUM(0.025f, 6, 0.15f, new Vector3(97, 102, 105)),
SILVER(0.005f, 1, 2, new Vector3(176, 175, 171)),

View file

@ -98,6 +98,7 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
public void setDye(int dyeID)
{
this.dyeID = dyeID;
this.refresh();
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}