finish the destructor
This commit is contained in:
@@ -29,6 +29,7 @@ public class StorageCraft
|
||||
public static final int DETECTOR = 6;
|
||||
public static final int SOLDERER = 7;
|
||||
public static final int WIRELESS_TRANSMITTER = 8;
|
||||
public static final int DESTRUCTOR = 9;
|
||||
}
|
||||
|
||||
public static final String ID = "storagecraft";
|
||||
|
@@ -1,12 +1,21 @@
|
||||
package storagecraft.block;
|
||||
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import storagecraft.StorageCraft;
|
||||
import storagecraft.tile.TileDestructor;
|
||||
|
||||
public class BlockDestructor extends BlockBase implements ITileEntityProvider
|
||||
{
|
||||
private IIcon sideIcon;
|
||||
private IIcon connectedIcon;
|
||||
private IIcon disconnectedIcon;
|
||||
|
||||
public BlockDestructor()
|
||||
{
|
||||
super("destructor");
|
||||
@@ -17,4 +26,47 @@ public class BlockDestructor extends BlockBase implements ITileEntityProvider
|
||||
{
|
||||
return new TileDestructor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
player.openGui(StorageCraft.INSTANCE, StorageCraft.GUI.DESTRUCTOR, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
connectedIcon = register.registerIcon("storagecraft:destructorConnected");
|
||||
disconnectedIcon = register.registerIcon("storagecraft:destructorDisconnected");
|
||||
sideIcon = register.registerIcon("storagecraft:side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileDestructor tile = (TileDestructor) world.getTileEntity(x, y, z);
|
||||
|
||||
if (side == tile.getDirection().ordinal())
|
||||
{
|
||||
return tile.isConnected() ? connectedIcon : disconnectedIcon;
|
||||
}
|
||||
|
||||
return sideIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int damage)
|
||||
{
|
||||
if (side == 3)
|
||||
{
|
||||
return disconnectedIcon;
|
||||
}
|
||||
|
||||
return sideIcon;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,13 @@
|
||||
package storagecraft.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class ContainerDestructor extends ContainerBase
|
||||
{
|
||||
public ContainerDestructor(EntityPlayer player)
|
||||
{
|
||||
super(player);
|
||||
|
||||
addPlayerInventory(8, 50);
|
||||
}
|
||||
}
|
43
src/main/java/storagecraft/gui/GuiDestructor.java
Normal file
43
src/main/java/storagecraft/gui/GuiDestructor.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package storagecraft.gui;
|
||||
|
||||
import storagecraft.container.ContainerDestructor;
|
||||
import storagecraft.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import storagecraft.tile.TileDestructor;
|
||||
|
||||
public class GuiDestructor extends GuiBase
|
||||
{
|
||||
private TileDestructor destructor;
|
||||
|
||||
public GuiDestructor(ContainerDestructor container, TileDestructor destructor)
|
||||
{
|
||||
super(container, 176, 131);
|
||||
|
||||
this.destructor = destructor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y)
|
||||
{
|
||||
addSideButton(new SideButtonRedstoneMode(destructor));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture("gui/destructor.png");
|
||||
|
||||
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY)
|
||||
{
|
||||
drawString(7, 7, t("gui.storagecraft:destructor"));
|
||||
drawString(7, 39, t("container.inventory"));
|
||||
}
|
||||
}
|
@@ -7,6 +7,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import storagecraft.StorageCraft;
|
||||
import storagecraft.container.ContainerController;
|
||||
import storagecraft.container.ContainerDestructor;
|
||||
import storagecraft.container.ContainerDetector;
|
||||
import storagecraft.container.ContainerDrive;
|
||||
import storagecraft.container.ContainerExporter;
|
||||
@@ -16,6 +17,7 @@ import storagecraft.container.ContainerSolderer;
|
||||
import storagecraft.container.ContainerExternalStorage;
|
||||
import storagecraft.container.ContainerWirelessTransmitter;
|
||||
import storagecraft.tile.TileController;
|
||||
import storagecraft.tile.TileDestructor;
|
||||
import storagecraft.tile.TileDetector;
|
||||
import storagecraft.tile.TileDrive;
|
||||
import storagecraft.tile.TileExporter;
|
||||
@@ -49,6 +51,8 @@ public class GuiHandler implements IGuiHandler
|
||||
return new ContainerSolderer(player, (TileSolderer) tile);
|
||||
case StorageCraft.GUI.WIRELESS_TRANSMITTER:
|
||||
return new ContainerWirelessTransmitter(player, (TileWirelessTransmitter) tile);
|
||||
case StorageCraft.GUI.DESTRUCTOR:
|
||||
return new ContainerDestructor(player);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -85,6 +89,8 @@ public class GuiHandler implements IGuiHandler
|
||||
return new GuiSolderer((ContainerSolderer) getContainer(ID, player, tile), (TileSolderer) tile);
|
||||
case StorageCraft.GUI.WIRELESS_TRANSMITTER:
|
||||
return new GuiWirelessTransmitter((ContainerWirelessTransmitter) getContainer(ID, player, tile), (TileWirelessTransmitter) tile);
|
||||
case StorageCraft.GUI.DESTRUCTOR:
|
||||
return new GuiDestructor((ContainerDestructor) getContainer(ID, player, tile), (TileDestructor) tile);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,5 +1,11 @@
|
||||
package storagecraft.tile;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import storagecraft.util.InventoryUtils;
|
||||
|
||||
public class TileDestructor extends TileMachine
|
||||
{
|
||||
@Override
|
||||
@@ -11,6 +17,25 @@ public class TileDestructor extends TileMachine
|
||||
@Override
|
||||
public void updateMachine()
|
||||
{
|
||||
// @TODO: ...
|
||||
int frontX = xCoord + getDirection().offsetX;
|
||||
int frontY = yCoord + getDirection().offsetY;
|
||||
int frontZ = zCoord + getDirection().offsetZ;
|
||||
|
||||
Block front = worldObj.getBlock(frontX, frontY, frontZ);
|
||||
|
||||
if (front != Blocks.air)
|
||||
{
|
||||
List<ItemStack> drops = front.getDrops(worldObj, frontX, frontY, frontZ, worldObj.getBlockMetadata(frontX, frontY, frontZ), 0);
|
||||
|
||||
worldObj.setBlockToAir(frontX, frontY, frontZ);
|
||||
|
||||
for (ItemStack drop : drops)
|
||||
{
|
||||
if (!getController().push(drop))
|
||||
{
|
||||
InventoryUtils.dropStack(worldObj, drop, frontX, frontY, frontZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package storagecraft.util;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -56,27 +55,28 @@ public class InventoryUtils
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/cpw/ironchest/blob/master/src/main/java/cpw/mods/ironchest/BlockIronChest.java#L200
|
||||
public static void dropInventory(World world, IInventory inventory, int x, int y, int z)
|
||||
{
|
||||
Random random = world.rand;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
|
||||
if (stack == null)
|
||||
if (stack != null)
|
||||
{
|
||||
continue;
|
||||
dropStack(world, stack, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float xo = random.nextFloat() * 0.8F + 0.1F;
|
||||
float yo = random.nextFloat() * 0.8F + 0.1F;
|
||||
float zo = random.nextFloat() * 0.8F + 0.1F;
|
||||
public static void dropStack(World world, ItemStack stack, int x, int y, int z)
|
||||
{
|
||||
float xo = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float yo = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float zo = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (stack.stackSize > 0)
|
||||
{
|
||||
int amount = random.nextInt(21) + 10;
|
||||
int amount = world.rand.nextInt(21) + 10;
|
||||
|
||||
if (amount > stack.stackSize)
|
||||
{
|
||||
@@ -87,9 +87,9 @@ public class InventoryUtils
|
||||
|
||||
EntityItem entity = new EntityItem(world, (float) x + xo, (float) y + yo, (float) z + zo, new ItemStack(stack.getItem(), amount, stack.getItemDamage()));
|
||||
|
||||
entity.motionX = (float) random.nextGaussian() * 0.05F;
|
||||
entity.motionY = (float) random.nextGaussian() * 0.05F + 0.2F;
|
||||
entity.motionZ = (float) random.nextGaussian() * 0.05F;
|
||||
entity.motionX = (float) world.rand.nextGaussian() * 0.05F;
|
||||
entity.motionY = (float) world.rand.nextGaussian() * 0.05F + 0.2F;
|
||||
entity.motionZ = (float) world.rand.nextGaussian() * 0.05F;
|
||||
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
@@ -99,7 +99,6 @@ public class InventoryUtils
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void pushToInventorySlot(IInventory inventory, int i, ItemStack stack)
|
||||
{
|
||||
|
@@ -9,6 +9,7 @@ gui.storagecraft:exporter=Exporter
|
||||
gui.storagecraft:detector=Detector
|
||||
gui.storagecraft:solderer=Solderer
|
||||
gui.storagecraft:wirelessTransmitter=Wireless Transmitter
|
||||
gui.storagecraft:destructor=Destructor
|
||||
|
||||
misc.storagecraft:energyStored=%d / %d RF
|
||||
misc.storagecraft:energyUsage=Usage: %d RF/t
|
||||
@@ -67,6 +68,7 @@ block.storagecraft:detector.name=Detector
|
||||
block.storagecraft:machineCasing.name=Machine Casing
|
||||
block.storagecraft:solderer.name=Solderer
|
||||
block.storagecraft:wirelessTransmitter.name=Wireless Transmitter
|
||||
block.storagecraft:destructor.name=Destructor
|
||||
|
||||
item.storagecraft:storageCell.0.name=1k Storage Cell
|
||||
item.storagecraft:storageCell.1.name=4k Storage Cell
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 353 B |
Binary file not shown.
After Width: | Height: | Size: 352 B |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Reference in New Issue
Block a user