A few fixes

This commit is contained in:
Aidan Brady 2013-12-13 17:13:46 -05:00
parent 0a0f3a1779
commit a05870a2ef
4 changed files with 78 additions and 129 deletions

View file

@ -41,7 +41,8 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
return "mekanism:mechanical_pipe";
}
public static void registerIcons(IconRegister register){
public static void registerIcons(IconRegister register)
{
pipeIcons = new PartTransmitterIcons(2);
pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipe", "MechanicalPipeActive"});
pipeIcons.registerSideIcon(register, "MechanicalPipeSide");

View file

@ -106,7 +106,6 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends TM
public abstract Icon getSideIcon();
@Override
public void bind(TileMultipart t)
{
@ -126,12 +125,12 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends TM
{
if(world().isRemote)
{
if(delayTicks == 3)
if(delayTicks == 5)
{
delayTicks++;
delayTicks = 6; /* don't refresh again */
refreshTransmitterNetwork();
}
else if(delayTicks < 3)
else if(delayTicks < 5)
{
delayTicks++;
}
@ -194,7 +193,6 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends TM
{
connections |= 1 << side.ordinal();
}
}
}
@ -375,7 +373,8 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends TM
if(connectionMapContainsSide(possibleTransmitters, side))
{
TileEntity cable = Object3D.get(tile()).getFromSide(side).getTileEntity(world());
if(TransmissionType.checkTransmissionType(cable, TransmissionType.ENERGY) && ((ITransmitter<N>)cable).getTransmitterNetwork(false) != null)
if(TransmissionType.checkTransmissionType(cable, getTransmissionType()) && ((ITransmitter<N>)cable).getTransmitterNetwork(false) != null)
{
connectedNets.add(((ITransmitter<N>)cable).getTransmitterNetwork());
}
@ -477,7 +476,9 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends TM
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
if(item == null)
{
return false;
}
if(item.getItem() instanceof ItemConfigurator && player.isSneaking())
{
isActive ^= true;

View file

@ -1,64 +0,0 @@
package universalelectricity.prefab;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
import universalelectricity.core.block.INetworkConnection;
/**
* A helper class to register chunk loading for your wires if you need them to be refreshed upon
* chunk load. This prevents the need for your wire to be refreshed.
*
* @author Calclavia, Aidancbrady
*
*/
public class ConductorChunkInitiate
{
private static boolean onChunkLoadRegistered = false;
/**
* Registers and initiates Universal Electricity's network loader.
*/
public static void register()
{
if (!onChunkLoadRegistered)
{
try
{
MinecraftForge.EVENT_BUS.register(new ConductorChunkInitiate());
onChunkLoadRegistered = true;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
@ForgeSubscribe
public void onChunkLoad(ChunkEvent.Load event)
{
if (event.getChunk() != null)
{
Collection<?> collection = new ArrayList();
collection.addAll(event.getChunk().chunkTileEntityMap.values());
for (Object obj : collection)
{
if (obj instanceof TileEntity)
{
TileEntity tileEntity = (TileEntity) obj;
if (tileEntity instanceof INetworkConnection)
{
((INetworkConnection) tileEntity).refresh();
}
}
}
}
}
}

View file

@ -8,11 +8,15 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/** A block that can rotate based on placed position and wrenching.
/**
* A block that can rotate based on placed position and wrenching.
*
* @author Calclavia */
* @author Calclavia
*/
public abstract class BlockRotatable extends BlockTile implements IRotatableBlock
{
protected byte rotationMask = 60;
public BlockRotatable(int id, Material material)
{
super(id, material);
@ -49,18 +53,25 @@ public abstract class BlockRotatable extends BlockTile implements IRotatableBloc
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
this.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side));
return this.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side));
}
@Override
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis)
{
int currentRotMeta = worldObj.getBlockMetadata(x, y, z);
ForgeDirection orientation = ForgeDirection.getOrientation(currentRotMeta);
ForgeDirection rotated = orientation.getRotation(axis);
int rmeta = rotated.ordinal();
int rmetaBit = 1 << rmeta;
System.out.println(rmetaBit + ": " + (rmetaBit & this.rotationMask));
if ((rmetaBit & this.rotationMask) == rmetaBit)
{
worldObj.setBlockMetadataWithNotify(x, y, z, rmeta, 3);
return true;
}
public static boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis, int mask)
{
int rotMeta = worldObj.getBlockMetadata(x, y, z);
int masked = rotMeta & ~mask;
ForgeDirection orientation = ForgeDirection.getOrientation(rotMeta & mask);
ForgeDirection rotated = orientation.getRotation(axis);
worldObj.setBlockMetadataWithNotify(x, y, z, rotated.ordinal() & mask | masked, 3);
return true;
return false;
}
@Override