Fixed turntable messing up multipart

This commit is contained in:
Calclavia 2014-01-28 21:08:09 +08:00
parent 4acf402225
commit af4ce9b93c
4 changed files with 40 additions and 21 deletions

View file

@ -14,6 +14,7 @@ import resonantinduction.core.prefab.block.BlockRIRotatable;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.block.IRotatableBlock;
import calclavia.lib.prefab.tile.IRotatable;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -93,23 +94,26 @@ public class BlockTurntable extends BlockRIRotatable
TileEntity tileEntity = position.getTileEntity(world);
Block block = Block.blocksList[position.getBlockID(world)];
if (tileEntity instanceof IRotatable)
if (!(tileEntity instanceof TileMultipart))
{
ForgeDirection blockRotation = ((IRotatable) tileEntity).getDirection();
((IRotatable) tileEntity).setDirection(blockRotation.getRotation(facing.getOpposite()));
}
else if (block instanceof IRotatableBlock)
{
ForgeDirection blockRotation = ((IRotatableBlock) block).getDirection(world, position.intX(), position.intY(), position.intZ());
((IRotatableBlock) block).setDirection(world, position.intX(), position.intY(), position.intZ(), blockRotation.getRotation(facing.getOpposite()));
}
else if (block != null)
{
Block.blocksList[blockID].rotateBlock(world, position.intX(), position.intY(), position.intZ(), facing.getOpposite());
}
if (tileEntity instanceof IRotatable)
{
ForgeDirection blockRotation = ((IRotatable) tileEntity).getDirection();
((IRotatable) tileEntity).setDirection(blockRotation.getRotation(facing.getOpposite()));
}
else if (block instanceof IRotatableBlock)
{
ForgeDirection blockRotation = ((IRotatableBlock) block).getDirection(world, position.intX(), position.intY(), position.intZ());
((IRotatableBlock) block).setDirection(world, position.intX(), position.intY(), position.intZ(), blockRotation.getRotation(facing.getOpposite()));
}
else if (block != null)
{
Block.blocksList[blockID].rotateBlock(world, position.intX(), position.intY(), position.intZ(), facing.getOpposite());
}
world.markBlockForUpdate(position.intX(), position.intY(), position.intZ());
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "tile.piston.in", 0.5F, world.rand.nextFloat() * 0.15F + 0.6F);
world.markBlockForUpdate(position.intX(), position.intY(), position.intZ());
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "tile.piston.in", 0.5F, world.rand.nextFloat() * 0.15F + 0.6F);
}
}
catch (Exception e)
{

View file

@ -42,6 +42,10 @@ public class TileThermopile extends TileElectrical
{
coolingSources++;
}
else if (blockID == Block.snow.blockID)
{
coolingSources += 2;
}
else if (blockID == Block.ice.blockID)
{
coolingSources += 2;

View file

@ -105,12 +105,6 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
refresh();
}
@Override
public void onMoved()
{
refresh();
}
@Override
public void onNeighborChanged()
{

View file

@ -1,6 +1,7 @@
package resonantinduction.mechanical.network;
import resonantinduction.mechanical.gear.PartGearShaft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.vector.Vector3;
@ -146,4 +147,20 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
torque = nbt.getLong("torque");
angularVelocity = nbt.getFloat("angularVelocity");
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setLong("torque", torque);
nbt.setFloat("angularVelocity", angularVelocity);
}
}