api changes and bug fixes
Fixed: Liquid register event Fixed? Bucket and Vile stack lose on filling Added: IPipe interface to help ID pipes Added? Pipe drip effects
This commit is contained in:
parent
5075a97d10
commit
a57f3f9268
5 changed files with 83 additions and 10 deletions
6
minecraft/liquidmechanics/api/IPipe.java
Normal file
6
minecraft/liquidmechanics/api/IPipe.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package liquidmechanics.api;
|
||||
|
||||
public interface IPipe extends IColorCoded
|
||||
{
|
||||
|
||||
}
|
|
@ -32,6 +32,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.liquids.LiquidDictionary;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
@ -155,6 +156,7 @@ public class LiquidMechanics extends DummyModContainer
|
|||
GameRegistry.registerTileEntity(TileEntityGenerator.class, "lmGen");
|
||||
GameRegistry.registerTileEntity(TileEntitySink.class, "lmSink");
|
||||
System.out.println("Fluid Mechanics Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
|
||||
MinecraftForge.EVENT_BUS.register(LiquidHandler.class);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package liquidmechanics.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import liquidmechanics.api.helpers.ColorCode;
|
||||
import liquidmechanics.client.render.BlockRenderHelper;
|
||||
import liquidmechanics.common.LiquidMechanics;
|
||||
import liquidmechanics.common.TabLiquidMechanics;
|
||||
|
@ -12,6 +14,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import universalelectricity.prefab.BlockMachine;
|
||||
|
||||
public class BlockPipe extends BlockMachine
|
||||
|
@ -23,6 +27,7 @@ public class BlockPipe extends BlockMachine
|
|||
this.setHardness(1f);
|
||||
this.setBlockName("lmPipe");
|
||||
this.setResistance(3f);
|
||||
//this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +47,6 @@ public class BlockPipe extends BlockMachine
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which
|
||||
* neighbor changed (coordinates passed are their own) Args: x, y, z,
|
||||
|
|
|
@ -80,7 +80,22 @@ public class BlockSink extends BlockMachine
|
|||
LiquidStack drain = tank.drain(LiquidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (drain != null && drain.amount >= LiquidContainerRegistry.BUCKET_VOLUME)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.bucketWater));
|
||||
ItemStack var12 = new ItemStack(Item.bucketEmpty, 1, 0);
|
||||
if (!player.inventory.addItemStackToInventory(heldItem))
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityItem(world, (double) x + 0.5D, (double) y + 1.5D, (double) z + 0.5D, var12));
|
||||
}
|
||||
else if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
|
||||
}
|
||||
|
||||
--heldItem.stackSize;
|
||||
|
||||
if (heldItem.stackSize <= 0)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null);
|
||||
}
|
||||
tank.drain(LiquidContainerRegistry.BUCKET_VOLUME, true);
|
||||
return true;
|
||||
}
|
||||
|
@ -91,7 +106,22 @@ public class BlockSink extends BlockMachine
|
|||
LiquidStack drain = tank.drain(LiquidContainerRegistry.BUCKET_VOLUME / 4, false);
|
||||
if (drain != null && drain.amount >= LiquidContainerRegistry.BUCKET_VOLUME / 4)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.potion, 1, 0));
|
||||
ItemStack var12 = new ItemStack(Item.potion, 1, 0);
|
||||
if (!player.inventory.addItemStackToInventory(var12))
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityItem(world, (double) x + 0.5D, (double) y + 1.5D, (double) z + 0.5D, var12));
|
||||
}
|
||||
else if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
|
||||
}
|
||||
|
||||
--heldItem.stackSize;
|
||||
|
||||
if (heldItem.stackSize <= 0)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null);
|
||||
}
|
||||
tank.drain(LiquidContainerRegistry.BUCKET_VOLUME / 4, true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package liquidmechanics.common.tileentity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import liquidmechanics.api.IColorCoded;
|
||||
import liquidmechanics.api.IPipe;
|
||||
import liquidmechanics.api.IReadOut;
|
||||
import liquidmechanics.api.helpers.ColorCode;
|
||||
import liquidmechanics.api.helpers.connectionHelper;
|
||||
|
@ -10,12 +13,14 @@ import liquidmechanics.api.liquids.LiquidHandler;
|
|||
import liquidmechanics.common.LiquidMechanics;
|
||||
import liquidmechanics.common.handlers.UpdateConverter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
|
@ -30,7 +35,7 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
public class TileEntityPipe extends TileEntity implements ITankContainer, IReadOut, IColorCoded
|
||||
public class TileEntityPipe extends TileEntity implements ITankContainer, IReadOut, IPipe
|
||||
{
|
||||
private ColorCode color = ColorCode.NONE;
|
||||
|
||||
|
@ -50,13 +55,16 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
|
||||
this.validataConnections();
|
||||
this.color = ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
if (!worldObj.isRemote && ++count >= 20)
|
||||
if (++count >= 20)
|
||||
{
|
||||
count = 0;
|
||||
this.updatePressure();
|
||||
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
this.randomDisplayTick();
|
||||
}
|
||||
LiquidStack stack = stored.getLiquid();
|
||||
if (stack != null && stack.amount >= 0)
|
||||
if (!worldObj.isRemote && stack != null && stack.amount >= 0)
|
||||
{
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
|
@ -77,11 +85,11 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
{
|
||||
if (dir == ForgeDirection.UP && !color.getLiquidData().getCanFloat())
|
||||
{
|
||||
|
||||
/* do nothing */
|
||||
}
|
||||
else if (dir == ForgeDirection.DOWN && color.getLiquidData().getCanFloat())
|
||||
{
|
||||
|
||||
/* do nothing */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -105,6 +113,29 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
|
||||
}
|
||||
|
||||
public void randomDisplayTick()
|
||||
{
|
||||
Random random = new Random();
|
||||
LiquidStack stack = stored.getLiquid();
|
||||
if (stack != null && random.nextInt(10) == 0)
|
||||
{
|
||||
// TODO align this with the pipe model so not to drip where there is
|
||||
// no pipe
|
||||
double xx = (double) ((float) xCoord + random.nextDouble());
|
||||
double zz = (double) yCoord + .3D;
|
||||
double yy = (double) ((float) zCoord + random.nextDouble());
|
||||
|
||||
if (ColorCode.get(stack) != ColorCode.RED)
|
||||
{
|
||||
worldObj.spawnParticle("dripWater", xx, zz, yy, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldObj.spawnParticle("dripLava", xx, zz, yy, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the current color mark of the pipe
|
||||
*/
|
||||
|
@ -274,7 +305,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
{
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
//TODO switch side catch for IPressure
|
||||
// TODO switch side catch for IPressure
|
||||
if (this.color != ColorCode.NONE && ent instanceof TileEntityTank && ((TileEntityTank) ent).getColor() != ColorCode.NONE && color != ((TileEntityTank) ent).getColor())
|
||||
{
|
||||
connectedBlocks[i] = null;
|
||||
|
|
Loading…
Reference in a new issue