Merge branch 'development' into 1.8
Conflicts: build.properties src/main/java/mekanism/common/Mekanism.java src/main/java/mekanism/common/tile/TileEntityBin.java src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java src/main/java/mekanism/generators/common/MekanismGenerators.java src/main/java/mekanism/generators/common/tile/TileEntityWindTurbine.java src/main/java/mekanism/tools/common/MekanismTools.java
This commit is contained in:
commit
faad9762df
9 changed files with 134 additions and 67 deletions
|
@ -63,6 +63,11 @@ import mekanism.common.network.PacketWalkieTalkieState;
|
|||
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
@ -154,6 +159,14 @@ public class PacketHandler
|
|||
{
|
||||
output.writeByte((Byte)data);
|
||||
}
|
||||
else if(data instanceof ItemStack)
|
||||
{
|
||||
writeStack(output, (ItemStack)data);
|
||||
}
|
||||
else if(data instanceof NBTTagCompound)
|
||||
{
|
||||
writeNBT(output, (NBTTagCompound)data);
|
||||
}
|
||||
else if(data instanceof int[])
|
||||
{
|
||||
for(int i : (int[])data)
|
||||
|
@ -190,6 +203,67 @@ public class PacketHandler
|
|||
return new String(input.readBytes(input.readInt()).array());
|
||||
}
|
||||
|
||||
public static void writeStack(ByteBuf output, ItemStack stack)
|
||||
{
|
||||
output.writeInt(stack != null ? Item.getIdFromItem(stack.getItem()) : -1);
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
output.writeInt(stack.stackSize);
|
||||
output.writeInt(stack.getItemDamage());
|
||||
|
||||
if(stack.getTagCompound() != null && stack.getItem().getShareTag())
|
||||
{
|
||||
output.writeBoolean(true);
|
||||
writeNBT(output, stack.getTagCompound());
|
||||
}
|
||||
else {
|
||||
output.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack readStack(ByteBuf input)
|
||||
{
|
||||
int id = input.readInt();
|
||||
|
||||
if(id >= 0)
|
||||
{
|
||||
ItemStack stack = new ItemStack(Item.getItemById(id), input.readInt(), input.readInt());
|
||||
|
||||
if(input.readBoolean())
|
||||
{
|
||||
stack.setTagCompound(readNBT(input));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void writeNBT(ByteBuf output, NBTTagCompound nbtTags)
|
||||
{
|
||||
try {
|
||||
byte[] buffer = CompressedStreamTools.compress(nbtTags);
|
||||
|
||||
output.writeInt(buffer.length);
|
||||
output.writeBytes(buffer);
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
public static NBTTagCompound readNBT(ByteBuf input)
|
||||
{
|
||||
try {
|
||||
byte[] buffer = new byte[input.readInt()];
|
||||
input.readBytes(buffer);
|
||||
|
||||
return CompressedStreamTools.func_152457_a(buffer, new NBTSizeTracker(2097152L));
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayer(MessageContext context)
|
||||
{
|
||||
return Mekanism.proxy.getPlayer(context);
|
||||
|
|
|
@ -381,7 +381,7 @@ public class BlockBasic extends Block
|
|||
|
||||
if(bin.getItemCount() < bin.MAX_STORAGE)
|
||||
{
|
||||
if(bin.addTicks == 0)
|
||||
if(bin.addTicks == 0 && entityplayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
|
@ -390,7 +390,8 @@ public class BlockBasic extends Block
|
|||
bin.addTicks = 5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if(bin.addTicks > 0 && bin.getItemCount() > 0)
|
||||
{
|
||||
ItemStack[] inv = entityplayer.inventory.mainInventory;
|
||||
|
||||
for(int i = 0; i < inv.length; i++)
|
||||
|
@ -404,6 +405,7 @@ public class BlockBasic extends Block
|
|||
{
|
||||
ItemStack remain = bin.add(inv[i]);
|
||||
inv[i] = remain;
|
||||
bin.addTicks = 5;
|
||||
}
|
||||
|
||||
((EntityPlayerMP)entityplayer).sendContainerAndContentsToPlayer(entityplayer.openContainer, entityplayer.openContainer.getInventory());
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package mekanism.common.inventory;
|
||||
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.item.ItemBlockBasic;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
@ -77,11 +76,6 @@ public class InventoryBin
|
|||
return false;
|
||||
}
|
||||
|
||||
if(stack.isItemStackDamageable() && stack.isItemDamaged())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(stack.getItem() instanceof ItemBlockBasic && stack.getItemDamage() == 6)
|
||||
{
|
||||
return false;
|
||||
|
@ -132,16 +126,7 @@ public class InventoryBin
|
|||
return null;
|
||||
}
|
||||
|
||||
int id = bin.stackTagCompound.getInteger("itemID");
|
||||
int meta = bin.stackTagCompound.getInteger("itemMeta");
|
||||
|
||||
if(getItemCount() == 0 || id == 0)
|
||||
{
|
||||
setItemType(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ItemStack(Item.getItemById(id), 1, meta);
|
||||
return ItemStack.loadItemStackFromNBT(bin.stackTagCompound.getCompoundTag("storedItem"));
|
||||
}
|
||||
|
||||
public void setItemType(ItemStack stack)
|
||||
|
@ -153,15 +138,12 @@ public class InventoryBin
|
|||
|
||||
if(stack == null)
|
||||
{
|
||||
bin.stackTagCompound.removeTag("itemID");
|
||||
bin.stackTagCompound.removeTag("itemMeta");
|
||||
bin.stackTagCompound.removeTag("storedItem");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack ret = stack.copy();
|
||||
ret.stackSize = 1;
|
||||
ItemStack ret = StackUtils.size(stack, 1);
|
||||
|
||||
bin.stackTagCompound.setInteger("itemID", MekanismUtils.getID(stack));
|
||||
bin.stackTagCompound.setInteger("itemMeta", stack.getItemDamage());
|
||||
bin.stackTagCompound.setTag("storedItem", StackUtils.size(stack, 1).writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
|||
@Method(modid = "CoFHAPI|energy")
|
||||
public boolean canConnectEnergy(ForgeDirection from)
|
||||
{
|
||||
return true;
|
||||
return canReceiveEnergy(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,10 +4,8 @@ import ic2.api.tile.IWrenchable;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.ITileComponent;
|
||||
|
@ -33,10 +31,10 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
|
|||
|
||||
public int clientFacing;
|
||||
|
||||
public Set<EntityPlayer> openedThisTick = Collections.synchronizedSet(new HashSet<EntityPlayer>());
|
||||
public HashSet<EntityPlayer> openedThisTick = new HashSet<EntityPlayer>();
|
||||
|
||||
/** The players currently using this block. */
|
||||
public Set<EntityPlayer> playersUsing = Collections.synchronizedSet(new HashSet<EntityPlayer>());
|
||||
public HashSet<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
||||
|
||||
/** A timer used to send packets to clients. */
|
||||
public int ticker;
|
||||
|
|
|
@ -6,20 +6,20 @@ import java.util.ArrayList;
|
|||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.ILogisticalTransporter;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.item.ItemBlockBasic;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -94,11 +94,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
|||
return false;
|
||||
}
|
||||
|
||||
if(stack.isItemStackDamageable() && stack.isItemDamaged())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(stack.getItem() instanceof ItemBlockBasic && stack.getItemDamage() == 6)
|
||||
{
|
||||
return false;
|
||||
|
@ -272,8 +267,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
|||
|
||||
if(getItemCount() > 0)
|
||||
{
|
||||
data.add(MekanismUtils.getID(itemType));
|
||||
data.add(itemType.getItemDamage());
|
||||
data.add(itemType);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -289,7 +283,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
|||
|
||||
if(clientAmount > 0)
|
||||
{
|
||||
itemType = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt());
|
||||
itemType = PacketHandler.readStack(dataStream);
|
||||
}
|
||||
else {
|
||||
itemType = null;
|
||||
|
@ -561,12 +555,8 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
|||
@Override
|
||||
public boolean onSneakRightClick(EntityPlayer player, int side)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
setActive(!getActive());
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1);
|
||||
}
|
||||
|
||||
setActive(!getActive());
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
|||
|
||||
if(getActive())
|
||||
{
|
||||
for(EntityPlayer player : playersUsing)
|
||||
for(EntityPlayer player : (HashSet<EntityPlayer>)playersUsing.clone())
|
||||
{
|
||||
if(player.openContainer instanceof ContainerNull || player.openContainer instanceof ContainerFilter)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ import mekanism.api.EnumColor;
|
|||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
|
@ -126,11 +127,28 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
}
|
||||
}
|
||||
|
||||
if(getEnergy() >= usage.fluidicPlenisherUsage && worldObj.getWorldTime() % 10 == 0 && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME && !finishedCalc)
|
||||
if(getEnergy() >= usage.fluidicPlenisherUsage && worldObj.getWorldTime() % 10 == 0 && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
|
||||
{
|
||||
if(fluidTank.getFluid().getFluid().canBePlacedInWorld())
|
||||
{
|
||||
doPlenish();
|
||||
if(!finishedCalc)
|
||||
{
|
||||
doPlenish();
|
||||
}
|
||||
else {
|
||||
Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);
|
||||
|
||||
if(canReplace(below, false) && getEnergy() >= usage.fluidicPlenisherUsage && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
|
||||
{
|
||||
if(fluidTank.getFluid().getFluid().canBePlacedInWorld())
|
||||
{
|
||||
worldObj.setBlock(below.xCoord, below.yCoord, below.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3);
|
||||
|
||||
setEnergy(getEnergy() - usage.fluidicPlenisherUsage);
|
||||
fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +168,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
{
|
||||
Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);
|
||||
|
||||
if(!canReplace(below))
|
||||
if(!canReplace(below, true))
|
||||
{
|
||||
finishedCalc = true;
|
||||
return;
|
||||
|
@ -168,7 +186,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
|
||||
for(Coord4D coord : activeNodes)
|
||||
{
|
||||
if(coord.exists(worldObj) && canReplace(coord))
|
||||
if(coord.exists(worldObj) && canReplace(coord, true))
|
||||
{
|
||||
worldObj.setBlock(coord.xCoord, coord.yCoord, coord.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3);
|
||||
|
||||
|
@ -179,7 +197,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
{
|
||||
Coord4D sideCoord = coord.getFromSide(dir);
|
||||
|
||||
if(coord.exists(worldObj) && canReplace(coord))
|
||||
if(coord.exists(worldObj) && canReplace(coord, true))
|
||||
{
|
||||
activeNodes.add(sideCoord);
|
||||
}
|
||||
|
@ -205,9 +223,9 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
return yCoord-1;
|
||||
}
|
||||
|
||||
public boolean canReplace(Coord4D coord)
|
||||
public boolean canReplace(Coord4D coord, boolean checkNodes)
|
||||
{
|
||||
if(usedNodes.contains(coord))
|
||||
if(checkNodes && usedNodes.contains(coord))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -217,6 +235,11 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
return true;
|
||||
}
|
||||
|
||||
if(MekanismUtils.isFluid(worldObj, coord.xCoord, coord.yCoord, coord.zCoord))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return coord.getBlock(worldObj).isReplaceable(worldObj, coord.xCoord, coord.yCoord, coord.zCoord);
|
||||
}
|
||||
|
||||
|
@ -400,7 +423,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection direction)
|
||||
{
|
||||
if(direction == ForgeDirection.getOrientation(1))
|
||||
if(direction == ForgeDirection.UP)
|
||||
{
|
||||
return new FluidTankInfo[] {fluidTank.getInfo()};
|
||||
}
|
||||
|
@ -469,14 +492,11 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
|||
@Override
|
||||
public boolean onSneakRightClick(EntityPlayer player, int side)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
activeNodes.clear();
|
||||
usedNodes.clear();
|
||||
finishedCalc = false;
|
||||
|
||||
player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.plenisherReset")));
|
||||
}
|
||||
activeNodes.clear();
|
||||
usedNodes.clear();
|
||||
finishedCalc = false;
|
||||
|
||||
player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.plenisherReset")));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import mekanism.common.IBoundingBlock;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.generators.common.MekanismGenerators;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
|
@ -47,10 +48,10 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
|
|||
{
|
||||
if(worldObj.canBlockSeeTheSky(xCoord, yCoord+4, zCoord))
|
||||
{
|
||||
final float minY = (float) generators.windGenerationMinY;
|
||||
final float maxY = (float) generators.windGenerationMaxY;
|
||||
final float minG = (float) generators.windGenerationMin;
|
||||
final float maxG = (float) generators.windGenerationMax;
|
||||
final float minY = (float)generators.windGenerationMinY;
|
||||
final float maxY = (float)generators.windGenerationMaxY;
|
||||
final float minG = (float)generators.windGenerationMin;
|
||||
final float maxG = (float)generators.windGenerationMax;
|
||||
|
||||
final float slope = (maxG - minG) / (maxY - minY);
|
||||
final float intercept = minG - slope * minY;
|
||||
|
|
Loading…
Add table
Reference in a new issue