Skip to content

Commit

Permalink
Make transmitters kinda sorta work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
unpairedbracket committed May 7, 2016
1 parent f183048 commit 918eadd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/main/java/mekanism/common/multipart/PartSidedPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,12 @@ protected void markDirtyTransmitters()

protected void markDirtyAcceptor(EnumFacing side) {}

public abstract void onWorldJoin();

@Override
public void onAdded()
{
onWorldJoin();
super.onAdded();

refreshConnections();
Expand All @@ -694,6 +697,7 @@ public void onAdded()
@Override
public void onLoaded()
{
onWorldJoin();
super.onLoaded();

//refreshConnections(); TODO causes StackOverflow. Why?
Expand Down
28 changes: 12 additions & 16 deletions src/main/java/mekanism/common/multipart/PartTransmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import mekanism.api.Coord4D;
import mekanism.api.IAlloyInteraction;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.DynamicNetwork.NetworkClientRequest;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.capabilities.Capabilities;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraft.util.EnumFacing;

Expand All @@ -32,29 +34,24 @@ public MultipartTransmitter<A, N> getTransmitter()
return transmitterDelegate;
}

/*
public abstract N createNewNetwork();

public abstract N createNetworkByMerging(Collection<N> networks);

@Override
public void onWorldJoin()
{
super.onWorldJoin();
if(!getWorld().isRemote)
{
TransmitterNetworkRegistry.registerOrphanTransmitter(getTransmitter());
}
else {
MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(tile()));
MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(getWorld().getTileEntity(getPos())));
}

unloaded = false;
}
*/

public abstract N createNewNetwork();

public abstract N createNetworkByMerging(Collection<N> networks);

/*
@Override
public void onUnloaded()
{
Expand All @@ -73,19 +70,18 @@ public void onUnloaded()
}

@Override
public void preRemove()
public void onRemoved()
{
if(!getWorld().isRemote)
{
TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter());
}
else {
} else
{
getTransmitter().setTransmitterNetwork(null);
}
super.preRemove();

super.onRemoved();
}
*/

@Override
public void markDirtyTransmitters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,12 @@ public EnergyNetwork createNewNetwork()
return new EnergyNetwork();
}

/*
@Override
public void onUnloaded()
{
takeShare();
super.onUnloaded();
}
*/

@Override
public Object getBuffer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ public void outputItems()
TileEntity tile = Coord4D.get(tileEntity).offset(side).getTileEntity(tileEntity.getWorld());
ItemStack prev = stack.copy();

if(tile instanceof IInventory && !(tile.hasCapability(Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite())))
if(tile instanceof IInventory && !(MekanismUtils.hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite())))
{
stack = InventoryUtils.putStackInInventory((IInventory)tile, stack, side, false);
}
else if(tile.hasCapability(Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite()))
else if(MekanismUtils.hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite()))
{
ItemStack rejects = TransporterUtils.insert(tileEntity, tile.getCapability(Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite()), stack, outputColor, true, 0);
ItemStack rejects = TransporterUtils.insert(tileEntity, MekanismUtils.getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite()), stack, outputColor, true, 0);

if(TransporterManager.didEmit(stack, rejects))
{
Expand Down

0 comments on commit 918eadd

Please sign in to comment.