Fix some stuff I missed in the merge, and server-client communication.
This commit is contained in:
parent
7a2461540f
commit
d29d1580bb
13 changed files with 53 additions and 41 deletions
|
@ -6,6 +6,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.transmitters.ITransmitterTile;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -18,28 +19,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
*/
|
||||
public final class GasTransmission
|
||||
{
|
||||
/**
|
||||
* Gets all the tubes around a tile entity.
|
||||
* @param tileEntity - center tile entity
|
||||
* @return array of TileEntities
|
||||
*/
|
||||
public static TileEntity[] getConnectedTubes(TileEntity tileEntity)
|
||||
{
|
||||
TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null};
|
||||
|
||||
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tube = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, tileEntity))
|
||||
{
|
||||
tubes[orientation.ordinal()] = tube;
|
||||
}
|
||||
}
|
||||
|
||||
return tubes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the acceptors around a tile entity.
|
||||
* @param tileEntity - center tile entity
|
||||
|
@ -92,7 +71,7 @@ public final class GasTransmission
|
|||
*/
|
||||
public static boolean canConnect(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if(tileEntity instanceof ITubeConnection && (!(tileEntity instanceof IGasTransmitter) || TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, tileEntity)))
|
||||
if(tileEntity instanceof ITubeConnection && (!(tileEntity instanceof ITransmitterTile) || TransmissionType.checkTransmissionType(((ITransmitterTile)tileEntity).getTransmitter(), TransmissionType.GAS)))
|
||||
{
|
||||
if(((ITubeConnection)tileEntity).canTubeConnect(side.getOpposite()))
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ import mekanism.api.transmitters.IGridTransmitter;
|
|||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface IGasTransmitter extends IGridTransmitter<GasNetwork>
|
||||
public interface IGasTransmitter extends IGridTransmitter<IGasHandler, GasNetwork>
|
||||
{
|
||||
public boolean canTransferGasToTube(TileEntity tile);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
public HashMap<Coord4D, EnumSet<ForgeDirection>> acceptorDirections = new HashMap<Coord4D, EnumSet<ForgeDirection>>();
|
||||
public HashMap<IGridTransmitter<A, N>, EnumSet<ForgeDirection>> changedAcceptors = new HashMap<>();
|
||||
|
||||
private List<DelayQueue> updateQueue = new ArrayList<DelayQueue>();
|
||||
private Set<DelayQueue> updateQueue = new LinkedHashSet<DelayQueue>();
|
||||
|
||||
protected Range4D packetRange = null;
|
||||
|
||||
|
@ -326,7 +326,8 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
q.delay--;
|
||||
} else
|
||||
{
|
||||
needsUpdate = true;
|
||||
transmittersAdded.addAll(transmitters);
|
||||
updateDelay = 1;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
@ -424,5 +425,17 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
player = p;
|
||||
delay = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return player.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return o instanceof DelayQueue && ((DelayQueue)o).player.equals(this.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ public class RenderPartTransmitter implements IIconSelfRegister
|
|||
GL11.glPushMatrix();
|
||||
entityItem.setEntityItemStack(stack.itemStack);
|
||||
|
||||
float[] pos = TransporterUtils.getStackPosition(transporter.getTransmitter(), stack, partialTick*transporter.getTransmitter().tier.speed);
|
||||
float[] pos = TransporterUtils.getStackPosition(transporter.getTransmitter(), stack, partialTick*transporter.tier.speed);
|
||||
|
||||
GL11.glTranslated(vec.x + pos[0], vec.y + pos[1] - entityItem.yOffset, vec.z + pos[2]);
|
||||
GL11.glScalef(0.75F, 0.75F, 0.75F);
|
||||
|
|
|
@ -30,8 +30,6 @@ public class MultipartTransporter extends MultipartTransmitter<IInventory, Inven
|
|||
{
|
||||
public HashList<TransporterStack> transit = new HashList<>();
|
||||
|
||||
public static final int SPEED = 5;
|
||||
|
||||
public EnumColor color;
|
||||
|
||||
public Set<TransporterStack> needsSync = new HashSet<>();
|
||||
|
@ -49,7 +47,7 @@ public class MultipartTransporter extends MultipartTransmitter<IInventory, Inven
|
|||
{
|
||||
if(stack != null)
|
||||
{
|
||||
stack.progress = Math.min(100, stack.progress+SPEED);
|
||||
stack.progress = Math.min(100, stack.progress+getPart().tier.speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +67,7 @@ public class MultipartTransporter extends MultipartTransmitter<IInventory, Inven
|
|||
}
|
||||
}
|
||||
|
||||
stack.progress += SPEED;
|
||||
stack.progress += getPart().tier.speed;
|
||||
|
||||
if(stack.progress > 100)
|
||||
{
|
||||
|
@ -85,7 +83,7 @@ public class MultipartTransporter extends MultipartTransmitter<IInventory, Inven
|
|||
if(next != null && stack.canInsertToTransporter(stack.getNext(this).getTileEntity(world()), ForgeDirection.getOrientation(stack.getSide(this))))
|
||||
{
|
||||
ITransporterTile nextTile = (ITransporterTile)next.getTileEntity(world());
|
||||
nextTile.getTransmitter().entityEntering(stack);
|
||||
nextTile.getTransmitter().entityEntering(stack, stack.progress%100);
|
||||
remove.add(stack);
|
||||
|
||||
continue;
|
||||
|
@ -325,9 +323,9 @@ public class MultipartTransporter extends MultipartTransmitter<IInventory, Inven
|
|||
}
|
||||
|
||||
@Override
|
||||
public void entityEntering(TransporterStack stack)
|
||||
public void entityEntering(TransporterStack stack, int progress)
|
||||
{
|
||||
stack.progress = 0;
|
||||
stack.progress = progress;
|
||||
transit.add(stack);
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), new Range4D(coord()));
|
||||
MekanismUtils.saveChunk(getPart().tile());
|
||||
|
|
|
@ -6,6 +6,7 @@ import mekanism.api.Coord4D;
|
|||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Tier.TransporterTier;
|
||||
import mekanism.common.content.transporter.TransporterStack;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -43,13 +44,13 @@ public class PartDiversionTransporter extends PartLogisticalTransporter
|
|||
@Override
|
||||
public IIcon getSideIcon(boolean opaque)
|
||||
{
|
||||
return transporterIcons.getSideIcon(opaque ? 14 : (color != null ? 11 : 10));
|
||||
return transporterIcons.getSideIcon(opaque ? 14 : (getTransmitter().color != null ? 11 : 10));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getSideIconRotated(boolean opaque)
|
||||
{
|
||||
return transporterIcons.getSideIcon(opaque ? 15 : (color != null ? 13 : 12));
|
||||
return transporterIcons.getSideIcon(opaque ? 15 : (getTransmitter().color != null ? 13 : 12));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,7 +42,6 @@ import io.netty.buffer.ByteBuf;
|
|||
|
||||
import codechicken.lib.vec.Vector3;
|
||||
|
||||
|
||||
public class PartLogisticalTransporter extends PartTransmitter<IInventory, InventoryNetwork> implements ITransporterTile
|
||||
{
|
||||
public Tier.TransporterTier tier = Tier.TransporterTier.BASIC;
|
||||
|
@ -53,7 +52,12 @@ public class PartLogisticalTransporter extends PartTransmitter<IInventory, Inven
|
|||
|
||||
public PartLogisticalTransporter(TransporterTier transporterTier)
|
||||
{
|
||||
super();
|
||||
tier = transporterTier;
|
||||
}
|
||||
|
||||
public PartLogisticalTransporter()
|
||||
{
|
||||
transmitterDelegate = new MultipartTransporter(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import codechicken.lib.vec.Vector3;
|
|||
|
||||
public class PartMechanicalPipe extends PartTransmitter<IFluidHandler, FluidNetwork> implements IFluidHandler
|
||||
{
|
||||
public static TransmitterIcons pipeIcons = new TransmitterIcons(4, 2);
|
||||
public static TransmitterIcons pipeIcons = new TransmitterIcons(4, 8);
|
||||
|
||||
public float currentScale;
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class PartMechanicalPipe extends PartTransmitter<IFluidHandler, FluidNetw
|
|||
@Override
|
||||
public void takeShare()
|
||||
{
|
||||
if(getTransmitter().hasTransmitterNetwork())
|
||||
if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetwork().buffer != null && lastWrite != null)
|
||||
{
|
||||
getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite.amount;
|
||||
buffer.setFluid(lastWrite);
|
||||
|
|
|
@ -198,7 +198,7 @@ public class PartPressurizedTube extends PartTransmitter<IGasHandler, GasNetwork
|
|||
@Override
|
||||
public TransmitterType getTransmitterType()
|
||||
{
|
||||
return TransmitterType.PRESSURIZED_TUBE;
|
||||
return tier.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package mekanism.common.multipart;
|
||||
|
||||
import mekanism.common.Tier.TransporterTier;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
|
|
|
@ -3,8 +3,11 @@ package mekanism.common.multipart;
|
|||
import java.util.Collection;
|
||||
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.DynamicNetwork.NetworkClientRequest;
|
||||
import mekanism.api.transmitters.ITransmitterTile;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends PartSidedPipe implements ITransmitterTile<A, N>
|
||||
|
@ -30,6 +33,10 @@ public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends
|
|||
{
|
||||
TransmitterNetworkRegistry.registerOrphanTransmitter(getTransmitter());
|
||||
}
|
||||
else
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(tile()));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract N createNewNetwork();
|
||||
|
|
|
@ -45,7 +45,10 @@ public class PacketDataRequest implements IMessageHandler<DataRequestMessage, IM
|
|||
{
|
||||
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
||||
|
||||
transmitter.getTransmitterNetwork().addUpdate(player);
|
||||
if(transmitter.hasTransmitterNetwork())
|
||||
{
|
||||
transmitter.getTransmitterNetwork().addUpdate(player);
|
||||
}
|
||||
}
|
||||
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(tileEntity), ((ITileNetwork)tileEntity).getNetworkedData(new ArrayList())), (EntityPlayerMP)player);
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package mekanism.common.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.transmitters.ITransmitterTile;
|
||||
|
||||
|
|
Loading…
Reference in a new issue