Dispensers can now latch balloons onto nearby entities, also working Portable Tank GUI
This commit is contained in:
parent
5852b59b50
commit
7924531a4e
7 changed files with 89 additions and 36 deletions
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -312,6 +313,15 @@ public class Coord4D
|
|||
{
|
||||
return world.isAirBlock(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a bounding box that contains the area this Coord4D would take up in a world.
|
||||
* @return this Coord4D's bounding box
|
||||
*/
|
||||
public AxisAlignedBB getBoundingBox()
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+1, zCoord+1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coord4D clone()
|
||||
|
|
|
@ -31,15 +31,15 @@ public class GuiPortableTank extends GuiMekanism
|
|||
{
|
||||
return tileEntity.fluidTank;
|
||||
}
|
||||
}, GuiFluidGauge.Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 55, 18));
|
||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 145, 19).with(SlotOverlay.INPUT));
|
||||
}, GuiFluidGauge.Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 48, 18));
|
||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 145, 18).with(SlotOverlay.INPUT));
|
||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 145, 50).with(SlotOverlay.OUTPUT));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 43, 6, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 47, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
|
|
|
@ -585,6 +585,9 @@ public class Mekanism
|
|||
"TET", "CIC", "GFG", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('C'), "circuitBasic", Character.valueOf('G'), MekanismUtils.getEmptyGasTank(),
|
||||
Character.valueOf('I'), new ItemStack(MachineBlock, 1, 0), Character.valueOf('F'), new ItemStack(BasicBlock, 1, 9)
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MachineBlock2, 1, 11), new Object[] {
|
||||
"III", "GCG", "III", Character.valueOf('I'), "ingotIron", Character.valueOf('G'), Blocks.glass, Character.valueOf('C'), "circuitBasic"
|
||||
}));
|
||||
|
||||
for(RecipeType type : RecipeType.values())
|
||||
{
|
||||
|
|
|
@ -737,7 +737,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
}
|
||||
else if(type == MachineType.PORTABLE_TANK)
|
||||
{
|
||||
if(!entityplayer.isSneaking())
|
||||
if(entityplayer.getCurrentEquippedItem() != null && FluidContainerRegistry.isContainer(entityplayer.getCurrentEquippedItem()))
|
||||
{
|
||||
manageInventory(entityplayer, (TileEntityPortableTank)tileEntity);
|
||||
}
|
||||
|
@ -1176,12 +1176,16 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
MachineType type = MachineType.get(this, world.getBlockMetadata(x, y, z));
|
||||
|
||||
if(metadata == MachineType.CHARGEPAD.meta)
|
||||
if(type == MachineType.CHARGEPAD)
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F);
|
||||
}
|
||||
else if(type == MachineType.PORTABLE_TANK)
|
||||
{
|
||||
setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F);
|
||||
}
|
||||
else {
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
@ -1201,14 +1205,18 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
MachineType type = MachineType.get(this, world.getBlockMetadata(x, y, z));
|
||||
|
||||
if(metadata != MachineType.CHARGEPAD.meta)
|
||||
if(type == MachineType.CHARGEPAD)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
else if(type == MachineType.PORTABLE_TANK)
|
||||
{
|
||||
return side == ForgeDirection.UP || side == ForgeDirection.DOWN;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ContainerPortableTank extends Container
|
|||
public ContainerPortableTank(InventoryPlayer inventory, TileEntityPortableTank tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new Slot(tentity, 0, 146, 20));
|
||||
addSlotToContainer(new Slot(tentity, 0, 146, 19));
|
||||
addSlotToContainer(new SlotOutput(tentity, 1, 146, 51));
|
||||
int slotX;
|
||||
|
||||
|
|
|
@ -168,34 +168,62 @@ public class ItemBalloon extends ItemMekanism
|
|||
{
|
||||
Coord4D coord = new Coord4D(source.getXInt(), source.getYInt(), source.getZInt(), source.getWorld().provider.dimensionId);
|
||||
ForgeDirection side = ForgeDirection.getOrientation(BlockDispenser.func_149937_b(source.getBlockMetadata()).ordinal());
|
||||
|
||||
List<EntityLivingBase> entities = source.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, coord.getFromSide(side).getBoundingBox());
|
||||
boolean latched = false;
|
||||
|
||||
Pos3D pos = new Pos3D(coord);
|
||||
|
||||
switch(side)
|
||||
for(EntityLivingBase entity : entities)
|
||||
{
|
||||
case DOWN:
|
||||
pos.translate(0, -2.5, 0);
|
||||
break;
|
||||
case UP:
|
||||
pos.translate(0, 0, 0);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.translate(0, -1, -0.5);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.translate(0, -1, 0.5);
|
||||
break;
|
||||
case WEST:
|
||||
pos.translate(-0.5, -1, 0);
|
||||
break;
|
||||
case EAST:
|
||||
pos.translate(0.5, -1, 0);
|
||||
break;
|
||||
AxisAlignedBB bound = AxisAlignedBB.getBoundingBox(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, entity.posX + 0.2, entity.posY + entity.ySize + 4, entity.posZ + 0.2);
|
||||
|
||||
List<EntityBalloon> balloonsNear = source.getWorld().getEntitiesWithinAABB(EntityBalloon.class, bound);
|
||||
boolean hasBalloon = false;
|
||||
|
||||
for(EntityBalloon balloon : balloonsNear)
|
||||
{
|
||||
if(balloon.latchedEntity == entity)
|
||||
{
|
||||
hasBalloon = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasBalloon)
|
||||
{
|
||||
source.getWorld().spawnEntityInWorld(new EntityBalloon(entity, getColor(stack)));
|
||||
latched = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!source.getWorld().isRemote)
|
||||
if(!latched)
|
||||
{
|
||||
source.getWorld().spawnEntityInWorld(new EntityBalloon(source.getWorld(), pos.xPos, pos.yPos, pos.zPos, getColor(stack)));
|
||||
Pos3D pos = new Pos3D(coord);
|
||||
|
||||
switch(side)
|
||||
{
|
||||
case DOWN:
|
||||
pos.translate(0, -2.5, 0);
|
||||
break;
|
||||
case UP:
|
||||
pos.translate(0, 0, 0);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.translate(0, -1, -0.5);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.translate(0, -1, 0.5);
|
||||
break;
|
||||
case WEST:
|
||||
pos.translate(-0.5, -1, 0);
|
||||
break;
|
||||
case EAST:
|
||||
pos.translate(0.5, -1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!source.getWorld().isRemote)
|
||||
{
|
||||
source.getWorld().spawnEntityInWorld(new EntityBalloon(source.getWorld(), pos.xPos, pos.yPos, pos.zPos, getColor(stack)));
|
||||
}
|
||||
}
|
||||
|
||||
stack.stackSize--;
|
||||
|
|
|
@ -119,12 +119,14 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
|||
if(stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
|
||||
{
|
||||
if(!block.isReplaceable(world, x, y, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outer:
|
||||
for(int xPos=-1;xPos<=1;xPos++)
|
||||
for(int xPos = -1; xPos <= 1; xPos++)
|
||||
{
|
||||
for(int zPos=-1;zPos<=1;zPos++)
|
||||
for(int zPos =- 1; zPos <= 1; zPos++)
|
||||
{
|
||||
if(!world.isAirBlock(x+xPos, y+2, z+zPos) || y+2 > 255)
|
||||
{
|
||||
|
@ -137,7 +139,9 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
|||
else if(stack.getItemDamage() == GeneratorType.WIND_TURBINE.meta)
|
||||
{
|
||||
if(!block.isReplaceable(world, x, y, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outer:
|
||||
for(int yPos = y+1; yPos <= y+4; yPos++)
|
||||
|
|
Loading…
Reference in a new issue