inserter crane
@ -5,6 +5,16 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IEnterableBlock {
|
||||
|
||||
/**
|
||||
* Returns true of the moving item can enter from the given side. When this happens, the IConveyorItem will call onEnter and despawn
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param dir
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public boolean canEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity);
|
||||
public void onEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity);
|
||||
}
|
||||
|
||||
@ -1899,7 +1899,7 @@ public class ModBlocks {
|
||||
|
||||
conveyor = new BlockConveyor().setBlockName("conveyor").setHardness(0.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor");
|
||||
crane_extractor = new CraneExtractor().setBlockName("crane_extractor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
crane_inserter = new CraneInserter().setBlockName("crane_extractor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
crane_inserter = new CraneInserter().setBlockName("crane_inserter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
|
||||
chain = new BlockChain(Material.iron).setBlockName("dungeon_chain").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":chain");
|
||||
|
||||
|
||||
@ -8,16 +8,13 @@ import com.hbm.explosion.ExplosionNT;
|
||||
import com.hbm.explosion.ExplosionNT.ExAttrib;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
|
||||
import api.hbm.conveyor.IConveyorItem;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class DetMiner extends BlockPillar implements IBomb, IEnterableBlock {
|
||||
public class DetMiner extends BlockPillar implements IBomb {
|
||||
|
||||
public DetMiner(Material mat, String top) {
|
||||
super(mat, top);
|
||||
@ -57,15 +54,4 @@ public class DetMiner extends BlockPillar implements IBomb, IEnterableBlock {
|
||||
this.explode(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity) {
|
||||
this.explode(world, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -57,7 +57,6 @@ public class BlockConveyor extends Block implements IConveyorBelt {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
||||
return Vec3.createVectorHelper(snap.xCoord + dir.offsetX * speed, snap.yCoord, snap.zCoord + dir.offsetZ * speed);*/
|
||||
|
||||
Vec3 snap = this.getClosestSnappingPosition(world, x, y, z, itemPos);
|
||||
/*double dist = snap.distanceTo(itemPos);
|
||||
|
||||
if(dist > speed) {
|
||||
@ -71,9 +70,24 @@ public class BlockConveyor extends Block implements IConveyorBelt {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
||||
return Vec3.createVectorHelper(snap.xCoord + dir.offsetX * speed, snap.yCoord, snap.zCoord + dir.offsetZ * speed);
|
||||
}*/
|
||||
|
||||
/// ATTEMT 2 ///
|
||||
/*Vec3 snap = this.getClosestSnappingPosition(world, x, y, z, itemPos);
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
||||
return Vec3.createVectorHelper(snap.xCoord - dir.offsetX * speed, snap.yCoord, snap.zCoord - dir.offsetZ * speed);*/
|
||||
/// ///
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
||||
return Vec3.createVectorHelper(snap.xCoord - dir.offsetX * speed, snap.yCoord, snap.zCoord - dir.offsetZ * speed);
|
||||
//snapping point
|
||||
Vec3 snap = this.getClosestSnappingPosition(world, x, y, z, itemPos);
|
||||
//snapping point + speed
|
||||
Vec3 dest = Vec3.createVectorHelper(snap.xCoord - dir.offsetX * speed, snap.yCoord, snap.zCoord - dir.offsetZ * speed);
|
||||
//delta to get to that point
|
||||
Vec3 motion = Vec3.createVectorHelper((dest.xCoord - itemPos.xCoord), (dest.yCoord - itemPos.yCoord), (dest.zCoord - itemPos.zCoord));
|
||||
double len = motion.lengthVector();
|
||||
//the effective destination towards "dest" after taking speed into consideration
|
||||
Vec3 ret = Vec3.createVectorHelper(itemPos.xCoord + motion.xCoord / len * speed, itemPos.yCoord + motion.yCoord / len * speed, itemPos.zCoord + motion.zCoord / len * speed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,7 +119,7 @@ public class BlockConveyor extends Block implements IConveyorBelt {
|
||||
if(entity instanceof EntityItem && entity.ticksExisted > 10 && !entity.isDead) {
|
||||
|
||||
EntityMovingItem item = new EntityMovingItem(world);
|
||||
item.setItemStack(((EntityItem) entity).getEntityItem());
|
||||
item.setItemStack(((EntityItem) entity).getEntityItem().copy());
|
||||
item.setPositionAndRotation(x + 0.5, y + 0.25, z + 0.5, 0, 0);
|
||||
world.spawnEntityInWorld(item);
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class BlockCraneBase extends BlockContainer {
|
||||
|
||||
@ -20,7 +21,10 @@ public abstract class BlockCraneBase extends BlockContainer {
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconSideIn;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconOut;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconSideOut;
|
||||
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectional;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalUp;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalDown;
|
||||
|
||||
public BlockCraneBase(Material mat) {
|
||||
super(mat);
|
||||
@ -37,12 +41,39 @@ public abstract class BlockCraneBase extends BlockContainer {
|
||||
this.iconSideOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_out");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract IIcon getIcon(int side, int metadata);
|
||||
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
int l = BlockPistonBase.determineOrientation(world, x, y, z, player);
|
||||
world.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
|
||||
if(side == 0 || side == 1) {
|
||||
if(side == metadata) {
|
||||
return this.iconOut;
|
||||
}
|
||||
if(side == ForgeDirection.getOrientation(metadata).getOpposite().ordinal()) {
|
||||
return this.iconIn;
|
||||
}
|
||||
|
||||
return side == 1 ? this.iconDirectional : this.blockIcon;
|
||||
}
|
||||
|
||||
if(side == metadata) {
|
||||
return this.iconSideOut;
|
||||
}
|
||||
if(side == ForgeDirection.getOrientation(metadata).getOpposite().ordinal()) {
|
||||
return this.iconSideIn;
|
||||
}
|
||||
|
||||
if(metadata == 0) {
|
||||
return this.iconDirectionalUp;
|
||||
}
|
||||
if(metadata == 1) {
|
||||
return this.iconDirectionalDown;
|
||||
}
|
||||
|
||||
return this.iconSide;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneExtractor;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CraneExtractor extends BlockCraneBase {
|
||||
@ -18,7 +18,7 @@ public class CraneExtractor extends BlockCraneBase {
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return null;
|
||||
return new TileEntityCraneExtractor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,10 +26,7 @@ public class CraneExtractor extends BlockCraneBase {
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return null;
|
||||
this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_up");
|
||||
this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_down");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,25 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.network.TileEntityCraneInserter;
|
||||
|
||||
import api.hbm.conveyor.IConveyorItem;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class CraneInserter extends BlockCraneBase{
|
||||
public class CraneInserter extends BlockCraneBase implements IEnterableBlock {
|
||||
|
||||
public CraneInserter() {
|
||||
super(Material.iron);
|
||||
@ -18,7 +27,7 @@ public class CraneInserter extends BlockCraneBase{
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return null;
|
||||
return new TileEntityCraneInserter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,10 +35,87 @@ public class CraneInserter extends BlockCraneBase{
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_top");
|
||||
this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_up");
|
||||
this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_down");
|
||||
}
|
||||
|
||||
@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) {
|
||||
return true;
|
||||
} else if(!player.isSneaking()) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return null;
|
||||
public boolean canEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity) {
|
||||
ForgeDirection orientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
||||
return orientation == dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity) {
|
||||
TileEntity te = world.getTileEntity(x - dir.offsetX, y - dir.offsetY, z - dir.offsetZ);
|
||||
|
||||
if(entity == null || entity.getItemStack() == null || entity.getItemStack().stackSize <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack toAdd = entity.getItemStack().copy();
|
||||
|
||||
int[] access = null;
|
||||
|
||||
if(te instanceof ISidedInventory) {
|
||||
ISidedInventory sided = (ISidedInventory) te;
|
||||
access = sided.getAccessibleSlotsFromSide(dir.ordinal());
|
||||
}
|
||||
|
||||
if(te instanceof IInventory) {
|
||||
IInventory inv = (IInventory) te;
|
||||
int limit = inv.getInventoryStackLimit();
|
||||
|
||||
int size = access == null ? inv.getSizeInventory() : access.length;
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
int index = access == null ? i : access[i];
|
||||
ItemStack stack = inv.getStackInSlot(index);
|
||||
|
||||
if(stack != null && toAdd.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(toAdd, stack) && stack.stackSize < Math.min(stack.getMaxStackSize(), limit)) {
|
||||
|
||||
int stackLimit = Math.min(stack.getMaxStackSize(), limit);
|
||||
int amount = Math.min(toAdd.stackSize, stackLimit - stack.stackSize);
|
||||
|
||||
stack.stackSize += amount;
|
||||
toAdd.stackSize -= amount;
|
||||
|
||||
if(toAdd.stackSize == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
int index = access == null ? i : access[i];
|
||||
ItemStack stack = inv.getStackInSlot(index);
|
||||
|
||||
if(stack == null && inv.isItemValidForSlot(index, stack)) {
|
||||
|
||||
int amount = Math.min(toAdd.stackSize, limit);
|
||||
|
||||
ItemStack newStack = toAdd.copy();
|
||||
newStack.stackSize = amount;
|
||||
inv.setInventorySlotContents(index, newStack);
|
||||
toAdd.stackSize -= amount;
|
||||
|
||||
if(toAdd.stackSize == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.hbm.entity.item;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
@ -40,7 +40,6 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack stack) {
|
||||
|
||||
this.getDataWatcher().updateObject(10, stack);
|
||||
this.getDataWatcher().setObjectWatched(10);
|
||||
}
|
||||
@ -170,9 +169,18 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
if(newBlock instanceof IEnterableBlock) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.UNKNOWN;
|
||||
|
||||
if(lastPos.getX() > newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.POS_X;
|
||||
else if(lastPos.getX() < newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.NEG_X;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() > newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.POS_Y;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() < newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.NEG_Y;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() > newPos.getZ()) dir = Library.POS_Z;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() < newPos.getZ()) dir = Library.NEG_Z;
|
||||
|
||||
IEnterableBlock enterable = (IEnterableBlock) newBlock;
|
||||
|
||||
if(enterable.canEnter(worldObj, newPos.getX(), newPos.getY(), newPos.getZ(), dir, this)) {
|
||||
|
||||
enterable.onEnter(worldObj, newPos.getX(), newPos.getY(), newPos.getZ(), dir, this);
|
||||
this.setDead();
|
||||
}
|
||||
@ -193,7 +201,7 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
this.syncPosX = x;
|
||||
this.syncPosY = y;
|
||||
this.syncPosZ = z;
|
||||
this.turnProgress = theNumberThree + 7; //use 4-ply for extra smoothness
|
||||
this.turnProgress = theNumberThree + 2; //use 4-ply for extra smoothness
|
||||
this.motionX = this.velocityX;
|
||||
this.motionY = this.velocityY;
|
||||
this.motionZ = this.velocityZ;
|
||||
|
||||
@ -10,6 +10,7 @@ import com.hbm.inventory.container.*;
|
||||
import com.hbm.inventory.gui.*;
|
||||
import com.hbm.inventory.inv.InventoryLeadBox;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.bomb.*;
|
||||
import com.hbm.tileentity.machine.*;
|
||||
import com.hbm.tileentity.machine.oil.*;
|
||||
@ -17,6 +18,7 @@ import com.hbm.tileentity.machine.rbmk.*;
|
||||
import com.hbm.tileentity.machine.storage.*;
|
||||
import com.hbm.tileentity.turret.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@ -29,6 +31,18 @@ public class GUIHandler implements IGuiHandler {
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity entity = world.getTileEntity(x, y, z);
|
||||
|
||||
if(entity instanceof IGUIProvider) {
|
||||
return ((IGUIProvider) entity).provideContainer(ID, player, world, x, y, z);
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if(block instanceof IGUIProvider) {
|
||||
return ((IGUIProvider) block).provideContainer(ID, player, world, x, y, z);
|
||||
}
|
||||
|
||||
//notice: stop doing this, unless you absolutely have to \/
|
||||
|
||||
if(entity instanceof TileEntityCrateIron) { return new ContainerCrateIron(player.inventory, (TileEntityCrateIron) entity); }
|
||||
if(entity instanceof TileEntityCrateSteel) { return new ContainerCrateSteel(player.inventory, (TileEntityCrateSteel) entity); }
|
||||
if(entity instanceof TileEntityCrateDesh) { return new ContainerCrateDesh(player.inventory, (TileEntityCrateDesh) entity); }
|
||||
@ -47,6 +61,8 @@ public class GUIHandler implements IGuiHandler {
|
||||
|
||||
if(entity instanceof TileEntityRBMKHeater) { return new ContainerRBMKHeater(player.inventory, (TileEntityRBMKHeater) entity); }
|
||||
|
||||
//notice: stop doing this completely, period \/
|
||||
|
||||
switch(ID) {
|
||||
case ModBlocks.guiID_test_difurnace: {
|
||||
if(entity instanceof TileEntityDiFurnace) {
|
||||
@ -854,6 +870,18 @@ public class GUIHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity entity = world.getTileEntity(x, y, z);
|
||||
|
||||
if(entity instanceof IGUIProvider) {
|
||||
return ((IGUIProvider) entity).provideGUI(ID, player, world, x, y, z);
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if(block instanceof IGUIProvider) {
|
||||
return ((IGUIProvider) block).provideGUI(ID, player, world, x, y, z);
|
||||
}
|
||||
|
||||
//stop doing this unless you absolutely have to \/
|
||||
|
||||
if(entity instanceof TileEntityCrateIron) { return new GUICrateIron(player.inventory, (TileEntityCrateIron) entity); }
|
||||
if(entity instanceof TileEntityCrateSteel) { return new GUICrateSteel(player.inventory, (TileEntityCrateSteel) entity); }
|
||||
@ -873,6 +901,8 @@ public class GUIHandler implements IGuiHandler {
|
||||
|
||||
if(entity instanceof TileEntityRBMKHeater) { return new GUIRBMKHeater(player.inventory, (TileEntityRBMKHeater) entity); }
|
||||
|
||||
//stop doing this, period \/
|
||||
|
||||
switch(ID) {
|
||||
case ModBlocks.guiID_test_difurnace: {
|
||||
if(entity instanceof TileEntityDiFurnace) {
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.tileentity.network.TileEntityCraneInserter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerCraneInserter extends Container {
|
||||
|
||||
protected TileEntityCraneInserter inserter;
|
||||
|
||||
public ContainerCraneInserter(InventoryPlayer invPlayer, TileEntityCraneInserter inserter) {
|
||||
this.inserter = inserter;
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 7; j++) {
|
||||
this.addSlotToContainer(new Slot(inserter, j + i * 7, 26 + j * 18, 17 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 20));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 20));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 <= inserter.getSizeInventory() - 1) {
|
||||
if(!this.mergeItemStack(var5, inserter.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, inserter.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(p_82846_1_, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return inserter.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
40
src/main/java/com/hbm/inventory/gui/GUICraneInserter.java
Normal file
@ -0,0 +1,40 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerCraneInserter;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneInserter;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUICraneInserter extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_crane_inserter.png");
|
||||
private TileEntityCraneInserter inserter;
|
||||
|
||||
public GUICraneInserter(InventoryPlayer invPlayer, TileEntityCraneInserter tedf) {
|
||||
super(new ContainerCraneInserter(invPlayer, tedf));
|
||||
inserter = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 185;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.inserter.hasCustomInventoryName() ? this.inserter.getInventoryName() : I18n.format(this.inserter.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@ -3,35 +3,79 @@ package com.hbm.render.block;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.network.BlockConveyor;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.util.ObjUtil;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
|
||||
public class RenderConveyor implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
public void renderInventoryBlock(Block block, int meta, int modelId, RenderBlocks renderer) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon iicon = block.getIcon(0, 0);
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
if(renderer.hasOverrideBlockTexture()) {
|
||||
iicon = renderer.overrideBlockTexture;
|
||||
}
|
||||
GL11.glTranslatef(-0.5F, -0.25F, -0.5F);
|
||||
renderer.setRenderBounds( 0D, 0D, 0D, 1D, 0.25D, 1D);
|
||||
|
||||
meta = 2;
|
||||
|
||||
GL11.glTranslated(0, -0.125, 0);
|
||||
if(meta == 2) {
|
||||
renderer.uvRotateTop = 3;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateWest = 3;
|
||||
}
|
||||
if(meta == 3) {
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 3;
|
||||
renderer.uvRotateEast = 3;
|
||||
}
|
||||
if(meta == 4) {
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateSouth = 3;
|
||||
}
|
||||
if(meta == 5) {
|
||||
renderer.uvRotateTop = 2;
|
||||
renderer.uvRotateBottom = 2;
|
||||
renderer.uvRotateNorth = 3;
|
||||
}
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.arrow, iicon, tessellator, 0, false);
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, meta));
|
||||
tessellator.draw();
|
||||
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateNorth = 0;
|
||||
renderer.uvRotateSouth = 0;
|
||||
renderer.uvRotateEast = 0;
|
||||
renderer.uvRotateWest = 0;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@ -20,23 +20,23 @@ public class RenderMovingItem extends Render {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
EntityMovingItem item = (EntityMovingItem)entity;
|
||||
ItemStack stack = item.getItemStack();
|
||||
|
||||
EntityMovingItem item = (EntityMovingItem) entity;
|
||||
ItemStack stack = item.getItemStack().copy();
|
||||
|
||||
if(!(stack.getItem() instanceof ItemBlock)) {
|
||||
GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glTranslated(0.0, -0.1875, 0.0);
|
||||
}
|
||||
|
||||
|
||||
EntityItem dummy = new EntityItem(entity.worldObj, 0, 0, 0, stack);
|
||||
dummy.getEntityItem().stackSize = 1;
|
||||
//dummy.getEntityItem().stackSize = 1;
|
||||
dummy.hoverStart = 0.0F;
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(dummy, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(dummy, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
15
src/main/java/com/hbm/tileentity/IGUIProvider.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGUIProvider {
|
||||
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
public class TileEntityCraneExtractor extends TileEntityMachineBase {
|
||||
|
||||
public TileEntityCraneExtractor() {
|
||||
super(20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "container.craneExtractor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.inventory.container.ContainerCraneInserter;
|
||||
import com.hbm.inventory.gui.GUICraneInserter;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityCraneInserter extends TileEntityMachineBase implements IGUIProvider {
|
||||
|
||||
public TileEntityCraneInserter() {
|
||||
super(21);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "container.craneInserter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerCraneInserter(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUICraneInserter(player.inventory, this);
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,6 @@ import com.hbm.inventory.RecipesCommon.MetaBlock;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.NoiseGeneratorPerlin;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@ -82,8 +81,8 @@ public class OreCave {
|
||||
|
||||
double scale = 0.01D;
|
||||
|
||||
for(int x = cX; x < cX + 16; x++) {
|
||||
for(int z = cZ; z < cZ + 16; z++) {
|
||||
for(int x = cX + 8; x < cX + 24; x++) {
|
||||
for(int z = cZ + 8; z < cZ + 24; z++) {
|
||||
|
||||
double n = noise.func_151601_a(x * scale, z * scale);
|
||||
|
||||
@ -105,7 +104,7 @@ public class OreCave {
|
||||
boolean canGenFluid = event.rand.nextBoolean();
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
Block neighbor = world.getBlock(MathHelper.clamp_int(x + dir.offsetX, cX, cX + 16), y + dir.offsetY, MathHelper.clamp_int(z + dir.offsetZ, cZ, cZ + 16));
|
||||
Block neighbor = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
if(neighbor.getMaterial() == Material.air || neighbor instanceof BlockStalagmite) {
|
||||
shouldGen = true;
|
||||
}
|
||||
@ -132,8 +131,8 @@ public class OreCave {
|
||||
|
||||
for(int i = 2; i < 6; i++) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
int clX = MathHelper.clamp_int(x + dir.offsetX, cX, cX + 16);
|
||||
int clZ = MathHelper.clamp_int(z + dir.offsetZ, cZ, cZ + 16);
|
||||
int clX = x + dir.offsetX;
|
||||
int clZ = z + dir.offsetZ;
|
||||
Block neighbor = world.getBlock(clX, y, clZ);
|
||||
|
||||
if(neighbor.isNormalCube())
|
||||
@ -146,7 +145,7 @@ public class OreCave {
|
||||
|
||||
} else {
|
||||
|
||||
if((genTarget.getMaterial() == Material.air || !genTarget.isNormalCube()) && event.rand.nextInt(5) == 0) {
|
||||
if((genTarget.getMaterial() == Material.air || !genTarget.isNormalCube()) && event.rand.nextInt(5) == 0 && !genTarget.getMaterial().isLiquid()) {
|
||||
|
||||
if(ModBlocks.stalactite.canPlaceBlockAt(world, x, y, z)) {
|
||||
world.setBlock(x, y, z, ModBlocks.stalactite, ore.meta, 2);
|
||||
|
||||
|
After Width: | Height: | Size: 259 B |
|
After Width: | Height: | Size: 259 B |
|
After Width: | Height: | Size: 253 B |
|
After Width: | Height: | Size: 254 B |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 380 B |
|
After Width: | Height: | Size: 375 B |
BIN
src/main/resources/assets/hbm/textures/models/turrets/arty.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |