Block breaker now semi-working
This commit is contained in:
parent
1e0ad25077
commit
73f13f5712
9 changed files with 250 additions and 107 deletions
|
@ -12,8 +12,6 @@ import resonantinduction.core.Settings;
|
|||
import resonantinduction.core.TabRI;
|
||||
import resonantinduction.mechanical.belt.BlockConveyorBelt;
|
||||
import resonantinduction.mechanical.belt.TileConveyorBelt;
|
||||
import resonantinduction.mechanical.blockeditor.BlockTileBreaker;
|
||||
import resonantinduction.mechanical.blockeditor.BlockTilePlacer;
|
||||
import resonantinduction.mechanical.energy.gear.ItemGear;
|
||||
import resonantinduction.mechanical.energy.gear.ItemGearShaft;
|
||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||
|
@ -32,6 +30,8 @@ import resonantinduction.mechanical.logistic.belt.TileDetector;
|
|||
import resonantinduction.mechanical.logistic.belt.TileManipulator;
|
||||
import resonantinduction.mechanical.logistic.belt.TileSorter;
|
||||
import resonantinduction.mechanical.process.crusher.TileMechanicalPiston;
|
||||
import resonantinduction.mechanical.process.edit.TileBreaker;
|
||||
import resonantinduction.mechanical.process.edit.TilePlacer;
|
||||
import resonantinduction.mechanical.process.grinder.TileGrindingWheel;
|
||||
import resonantinduction.mechanical.process.purifier.TileMixer;
|
||||
import calclavia.api.resonantinduction.IMechanicalNode;
|
||||
|
@ -137,8 +137,8 @@ public class Mechanical
|
|||
blockMechanicalPiston = contentRegistry.newBlock(TileMechanicalPiston.class);
|
||||
OreDictionary.registerOre("gear", itemGear);
|
||||
|
||||
blockTileBreaker = contentRegistry.newBlock(BlockTileBreaker.class);
|
||||
blockTilePlacer = contentRegistry.newBlock(BlockTilePlacer.class);
|
||||
blockTileBreaker = contentRegistry.newBlock(TileBreaker.class);
|
||||
blockTilePlacer = contentRegistry.newBlock(TilePlacer.class);
|
||||
|
||||
proxy.preInit();
|
||||
Settings.CONFIGURATION.save();
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
package resonantinduction.mechanical.blockeditor;
|
||||
|
||||
import calclavia.lib.content.module.prefab.TileInventory;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
|
||||
/**
|
||||
* @since 18/03/14
|
||||
* @author tgame14
|
||||
*/
|
||||
public class BlockTileBreaker extends TileInventory implements IRotatable
|
||||
{
|
||||
|
||||
public BlockTileBreaker ()
|
||||
{
|
||||
super("BlockTileBreaker", Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakRedstonePower (IBlockAccess access, int side)
|
||||
{
|
||||
ResonantInduction.LOGGER.info("Calling Weak Red on tile ");
|
||||
int facing = access.getBlockMetadata(x(), y(), z());
|
||||
if (facing != side)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(facing);
|
||||
Block block = Block.blocksList[access.getBlockId(x() + dir.offsetX, y() + dir.offsetY, z() + dir.offsetZ)];
|
||||
int candidateMeta = access.getBlockMetadata(x() + dir.offsetX, y() + dir.offsetY, z() + dir.offsetZ);
|
||||
boolean flag = true;
|
||||
for (ItemStack stack : block.getBlockDropped(getWorldObj(), x(), y(), z(), candidateMeta, 0))
|
||||
if (!this.canInsertItem(0, stack, facing))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
getWorldObj().destroyBlock(x() + dir.offsetX, y() + dir.offsetY, z(), false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return super.getWeakRedstonePower(access, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced (EntityLivingBase entityLiving, ItemStack itemStack)
|
||||
{
|
||||
super.onPlaced(entityLiving, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (ForgeDirection direction)
|
||||
{
|
||||
super.setDirection(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection ()
|
||||
{
|
||||
return super.getDirection();
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package resonantinduction.mechanical.blockeditor;
|
||||
|
||||
import calclavia.lib.content.module.prefab.TileInventory;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* @since 18/03/14
|
||||
* @author tgame14
|
||||
*/
|
||||
public class BlockTilePlacer extends TileInventory implements IRotatable
|
||||
{
|
||||
public BlockTilePlacer ()
|
||||
{
|
||||
super("BlockTilePlacer", Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakRedstonePower (IBlockAccess access, int side)
|
||||
{
|
||||
int facing = access.getBlockMetadata(x(), y(), z());
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(facing);
|
||||
if (access.isAirBlock(x() + dir.offsetX, y() + dir.offsetY, z() + dir.offsetZ))
|
||||
{
|
||||
getWorldObj().setBlock(x() + dir.offsetX, y() + dir.offsetY, z() + dir.offsetZ, getInventory().getContainedItems()[0].getItem().itemID);
|
||||
}
|
||||
|
||||
return super.getWeakRedstonePower(access, side);
|
||||
}
|
||||
}
|
|
@ -110,7 +110,7 @@ public class TileMechanicalPiston extends TileMechanical implements IRotatable
|
|||
}
|
||||
}
|
||||
|
||||
world().setBlockToAir(blockPos.intX(), blockPos.intY(), blockPos.intZ());
|
||||
getWorldObj().destroyBlock(blockPos.intX(), blockPos.intY(), blockPos.intZ(), false);
|
||||
}
|
||||
|
||||
breakCount = mechanicalPistonBreakCount;
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
package resonantinduction.mechanical.process.edit;
|
||||
|
||||
import calclavia.lib.content.module.TileRender;
|
||||
import calclavia.lib.content.module.prefab.TileInventory;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.render.RenderItemOverlayUtility;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import universalelectricity.api.vector.VectorWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author tgame14
|
||||
* @since 18/03/14
|
||||
*/
|
||||
public class TileBreaker extends TileInventory implements IRotatable, IPacketReceiver
|
||||
{
|
||||
public TileBreaker()
|
||||
{
|
||||
super(Material.iron);
|
||||
normalRender = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
work();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
work();
|
||||
}
|
||||
|
||||
public void work()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
ForgeDirection dir = getDirection();
|
||||
Vector3 check = position().translate(dir);
|
||||
VectorWorld put = (VectorWorld) position().translate(dir.getOpposite());
|
||||
|
||||
Block block = Block.blocksList[check.getBlockID(world())];
|
||||
|
||||
if (block != null)
|
||||
{
|
||||
int candidateMeta = world().getBlockMetadata(check.intX(), check.intY(), check.intZ());
|
||||
boolean flag = true;
|
||||
|
||||
ArrayList<ItemStack> drops = block.getBlockDropped(getWorldObj(), check.intX(), check.intY(), check.intZ(), candidateMeta, 0);
|
||||
|
||||
for (ItemStack stack : drops)
|
||||
{
|
||||
if (!canInsertItem(0, stack, dir.ordinal() ^ 1))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
getWorldObj().destroyBlock(check.intX(), check.intY(), check.intZ(), false);
|
||||
|
||||
for (ItemStack stack : drops)
|
||||
{
|
||||
InventoryUtility.putStackInInventory((VectorWorld) put.translate(0.5), stack, dir.ordinal(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected TileRender newRenderer()
|
||||
{
|
||||
return new TileRender()
|
||||
{
|
||||
@Override
|
||||
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
|
||||
{
|
||||
if (!isItem)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
RenderItemOverlayUtility.renderItemOnSides(TileBreaker.this, getStackInSlot(0), position.x, position.y, position.z);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package resonantinduction.mechanical.process.edit;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.content.module.TileRender;
|
||||
import calclavia.lib.content.module.prefab.TileInventory;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.render.RenderItemOverlayUtility;
|
||||
|
||||
/**
|
||||
* @since 18/03/14
|
||||
* @author tgame14
|
||||
*/
|
||||
public class TilePlacer extends TileInventory implements IRotatable, IPacketReceiver
|
||||
{
|
||||
public TilePlacer()
|
||||
{
|
||||
super(Material.iron);
|
||||
normalRender = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
work();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
work();
|
||||
}
|
||||
|
||||
public void work()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
ForgeDirection dir = getDirection();
|
||||
Vector3 check = position().translate(dir);
|
||||
ItemStack placeStack = getStackInSlot(0);
|
||||
|
||||
if (world().isAirBlock(check.intX(), check.intY(), check.intZ()) && placeStack != null && placeStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
ItemStack copyPlaceStack = placeStack.copy();
|
||||
decrStackSize(0, 1);
|
||||
((ItemBlock) copyPlaceStack.getItem()).placeBlockAt(placeStack, null, world(), check.intX(), check.intY(), check.intZ(), 0, 0, 0, 0, copyPlaceStack.getItemDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected TileRender newRenderer()
|
||||
{
|
||||
return new TileRender()
|
||||
{
|
||||
@Override
|
||||
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
|
||||
{
|
||||
if (!isItem)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
RenderItemOverlayUtility.renderItemOnSides(TilePlacer.this, getStackInSlot(0), position.x, position.y, position.z);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit de65db296a225c74e7477bf5105c852fafc797da
|
||||
Subproject commit ba1590e0a3bcde55dd1ed7d382567757db92fb50
|
Binary file not shown.
After Width: | Height: | Size: 830 B |
Binary file not shown.
After Width: | Height: | Size: 830 B |
Loading…
Reference in a new issue