Added mechanical piston
This commit is contained in:
parent
015868fba6
commit
2821f7b1e1
24 changed files with 308 additions and 57 deletions
|
@ -28,7 +28,7 @@ import resonantinduction.core.ResonantInduction;
|
|||
import resonantinduction.core.Settings;
|
||||
import resonantinduction.core.TabRI;
|
||||
import resonantinduction.core.prefab.imprint.ItemImprint;
|
||||
import resonantinduction.mechanical.gear.ItemHandCrank;
|
||||
import resonantinduction.core.resource.ItemHandCrank;
|
||||
import calclavia.lib.content.ContentRegistry;
|
||||
import calclavia.lib.network.PacketAnnotation;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package resonantinduction.archaic.piston;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.Reference;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderPiston extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "piston.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
|
||||
// Angle in radians of the rotor.
|
||||
float angle = 0;
|
||||
float radius = 0;
|
||||
// Length of piston arm
|
||||
float length = 0.8f;
|
||||
|
||||
double beta = Math.asin((radius * Math.sin(angle)) / length);
|
||||
|
||||
/**
|
||||
* Render Piston Arm
|
||||
*/
|
||||
GL11.glPushMatrix();
|
||||
double pistonTranslateX = 2 * length * Math.cos(beta);
|
||||
double pistonTranslateY = 2 * length * Math.sin(beta);
|
||||
|
||||
GL11.glTranslated(pistonTranslateX, 0, pistonTranslateY);
|
||||
GL11.glRotated(Math.toDegrees(beta), 0, 0, 1);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
/**
|
||||
* Render Piston Rotor
|
||||
*/
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotated(Math.toDegrees(angle), 0, 0, 1);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import net.minecraft.util.Icon;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.mechanical.gear.ItemHandCrank;
|
||||
import resonantinduction.core.resource.ItemHandCrank;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.block.BlockTile;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
|
|
|
@ -23,7 +23,6 @@ import resonantinduction.mechanical.fluid.transport.TileGrate;
|
|||
import resonantinduction.mechanical.fluid.transport.TilePump;
|
||||
import resonantinduction.mechanical.gear.ItemGear;
|
||||
import resonantinduction.mechanical.gear.ItemGearShaft;
|
||||
import resonantinduction.mechanical.gear.ItemHandCrank;
|
||||
import resonantinduction.mechanical.logistic.belt.BlockDetector;
|
||||
import resonantinduction.mechanical.logistic.belt.BlockManipulator;
|
||||
import resonantinduction.mechanical.logistic.belt.BlockRejector;
|
||||
|
@ -33,6 +32,8 @@ import resonantinduction.mechanical.logistic.belt.TileRejector;
|
|||
import resonantinduction.mechanical.network.PacketNetwork;
|
||||
import resonantinduction.mechanical.process.BlockFilter;
|
||||
import resonantinduction.mechanical.process.TileFilter;
|
||||
import resonantinduction.mechanical.process.crusher.BlockMechanicalPiston;
|
||||
import resonantinduction.mechanical.process.crusher.TileMechanicalPiston;
|
||||
import resonantinduction.mechanical.process.grinder.BlockGrindingWheel;
|
||||
import resonantinduction.mechanical.process.grinder.TileGrinderWheel;
|
||||
import resonantinduction.mechanical.process.purifier.BlockMixer;
|
||||
|
@ -104,6 +105,7 @@ public class Mechanical
|
|||
public static Block blockGrinderWheel;
|
||||
public static Block blockPurifier;
|
||||
public static Block blockFilter;
|
||||
public static Block blockMechanicalPiston;
|
||||
|
||||
public static final PacketNetwork PACKET_NETWORK = new PacketNetwork(IMechanical.class, Reference.CHANNEL);
|
||||
|
||||
|
@ -134,6 +136,7 @@ public class Mechanical
|
|||
blockGrinderWheel = contentRegistry.createTile(BlockGrindingWheel.class, TileGrinderWheel.class);
|
||||
blockPurifier = contentRegistry.createTile(BlockMixer.class, TileMixer.class);
|
||||
blockFilter = contentRegistry.createTile(BlockFilter.class, TileFilter.class);
|
||||
blockMechanicalPiston = contentRegistry.createTile(BlockMechanicalPiston.class, TileMechanicalPiston.class);
|
||||
OreDictionary.registerOre("gear", itemGear);
|
||||
|
||||
proxy.preInit();
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.api.mechanical.IMechanical;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.resource.ItemHandCrank;
|
||||
import resonantinduction.mechanical.Mechanical;
|
||||
import resonantinduction.mechanical.network.PartMechanical;
|
||||
import calclavia.lib.multiblock.reference.IMultiBlockStructure;
|
||||
|
|
|
@ -46,6 +46,12 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
|||
|
||||
angle += angularVelocity / 20;
|
||||
|
||||
if (angle % (Math.PI * 2) != angle)
|
||||
{
|
||||
revolve(angle <= Math.PI * 2 || angle >= Math.PI * 2);
|
||||
angle = (float) (angle % (Math.PI * 2));
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
torque *= getLoad();
|
||||
|
@ -65,6 +71,11 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
|||
}
|
||||
}
|
||||
|
||||
protected void revolve(boolean isAmplitude)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public long getPower()
|
||||
{
|
||||
return (long) (torque * angularVelocity);
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package resonantinduction.mechanical.process.crusher;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||
import calclavia.lib.prefab.block.BlockRotatable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A block used to build machines.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockMechanicalPiston extends BlockRotatable
|
||||
{
|
||||
public BlockMechanicalPiston(int id)
|
||||
{
|
||||
super(id, Material.wood);
|
||||
setTextureName(Reference.PREFIX + "material_steel_dark");
|
||||
rotationMask = Byte.parseByte("111111", 2);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return RIBlockRenderingHandler.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileMechanicalPiston();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package resonantinduction.mechanical.process.crusher;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import resonantinduction.core.Reference;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderMechanicalPiston extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "rejector.tcn");
|
||||
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "rejector.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
TileMechanicalPiston tile = (TileMechanicalPiston) tileEntity;
|
||||
GL11.glRotated(-90, 0, 1, 0);
|
||||
|
||||
if (tile.worldObj != null)
|
||||
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
|
||||
|
||||
RenderUtility.bind(TEXTURE);
|
||||
|
||||
// Angle in radians of the rotor.
|
||||
float angle = tile.angle;
|
||||
float radius = 0.5f;
|
||||
// Length of piston arm
|
||||
float length = 1f;
|
||||
|
||||
double beta = Math.asin((radius * Math.sin(angle)) / length);
|
||||
|
||||
/**
|
||||
* Render Piston Rod
|
||||
*/
|
||||
GL11.glPushMatrix();
|
||||
double pistonTranslateX = 2 * length * Math.cos(beta);
|
||||
double pistonTranslateY = 2 * length * Math.sin(beta);
|
||||
|
||||
GL11.glTranslated(pistonTranslateX, 0, pistonTranslateY);
|
||||
GL11.glRotated(Math.toDegrees(beta), 0, 0, 1);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
/**
|
||||
* Render Piston Rotor
|
||||
*/
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, 0, (0.5 * Math.cos(angle)) - 0.5);
|
||||
MODEL.renderOnly("PistonShaft", "PistonFace", "PistonFace2");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
MODEL.renderAllExcept("PistonShaft", "PistonFace", "PistonFace2");
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
package resonantinduction.mechanical.process.crusher;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.mechanical.network.TileMechanical;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.utility.MovementUtility;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class TileMechanicalPiston extends TileMechanical
|
||||
{
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
Vector3 movePosition = new Vector3(this).translate(getDirection());
|
||||
Vector3 moveNewPosition = movePosition.clone().translate(getDirection());
|
||||
|
||||
if (!canMove(movePosition, moveNewPosition))
|
||||
angle = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void revolve(boolean isAmplitude)
|
||||
{
|
||||
if (!worldObj.isRemote && isAmplitude)
|
||||
{
|
||||
Vector3 movePosition = new Vector3(this).translate(getDirection());
|
||||
Vector3 moveNewPosition = movePosition.clone().translate(getDirection());
|
||||
|
||||
if (canMove(movePosition, moveNewPosition))
|
||||
move(movePosition, moveNewPosition);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canMove(Vector3 from, Vector3 to)
|
||||
{
|
||||
TileEntity tileEntity = from.getTileEntity(worldObj);
|
||||
|
||||
if (to.getTileEntity(worldObj) == this)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Check Target */
|
||||
int targetBlockID = to.getBlockID(worldObj);
|
||||
|
||||
if (!(worldObj.isAirBlock(to.intX(), to.intY(), to.intZ()) || (targetBlockID > 0 && (Block.blocksList[targetBlockID].isBlockReplaceable(worldObj, to.intX(), to.intY(), to.intZ())))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void move(Vector3 from, Vector3 to)
|
||||
{
|
||||
int blockID = from.getBlockID(worldObj);
|
||||
int blockMetadata = from.getBlockMetadata(worldObj);
|
||||
|
||||
TileEntity tileEntity = from.getTileEntity(worldObj);
|
||||
|
||||
NBTTagCompound tileData = new NBTTagCompound();
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.writeToNBT(tileData);
|
||||
}
|
||||
|
||||
MovementUtility.setBlockSneaky(worldObj, from, 0, 0, null);
|
||||
|
||||
if (tileEntity != null && tileData != null)
|
||||
{
|
||||
/**
|
||||
* Forge Multipart Support. Use FMP's custom TE creator.
|
||||
*/
|
||||
boolean isMultipart = tileData.getString("id").equals("savedMultipart");
|
||||
|
||||
TileEntity newTile = null;
|
||||
|
||||
if (isMultipart)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
|
||||
Method m = multipart.getMethod("createTileFromNBT", World.class, NBTTagCompound.class);
|
||||
newTile = (TileEntity) m.invoke(null, worldObj, tileData);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newTile = TileEntity.createAndLoadEntity(tileData);
|
||||
}
|
||||
|
||||
MovementUtility.setBlockSneaky(worldObj, to, blockID, blockMetadata, newTile);
|
||||
|
||||
if (newTile != null && isMultipart)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Send the description packet of the TE after moving it.
|
||||
Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
|
||||
multipart.getMethod("sendDescPacket", World.class, TileEntity.class).invoke(null, worldObj, newTile);
|
||||
|
||||
// Call onMoved event.
|
||||
Class tileMultipart = Class.forName("codechicken.multipart.TileMultipart");
|
||||
tileMultipart.getMethod("onMoved").invoke(newTile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MovementUtility.setBlockSneaky(worldObj, to, blockID, blockMetadata, null);
|
||||
}
|
||||
|
||||
notifyChanges(from);
|
||||
notifyChanges(to);
|
||||
}
|
||||
|
||||
public void notifyChanges(Vector3 pos)
|
||||
{
|
||||
worldObj.notifyBlocksOfNeighborChange(pos.intX(), pos.intY(), pos.intZ(), pos.getBlockID(worldObj));
|
||||
|
||||
TileEntity newTile = pos.getTileEntity(worldObj);
|
||||
|
||||
if (newTile != null)
|
||||
{
|
||||
if (Loader.isModLoaded("BuildCraft|Factory"))
|
||||
{
|
||||
/**
|
||||
* Special quarry compatibility code.
|
||||
*/
|
||||
try
|
||||
{
|
||||
Class clazz = Class.forName("buildcraft.factory.TileQuarry");
|
||||
|
||||
if (clazz == newTile.getClass())
|
||||
{
|
||||
ReflectionHelper.setPrivateValue(clazz, newTile, true, "isAlive");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object source)
|
||||
{
|
||||
return from != getDirection();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import static org.lwjgl.opengl.GL11.glTranslatef;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.Reference;
|
||||
|
@ -22,7 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class RenderGrinderWheel extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final WavefrontObject MODEL = (WavefrontObject) AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "grinder.obj");
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "grinder.obj");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.mechanical.gear;
|
||||
package resonantinduction.core.resource;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -108,6 +108,7 @@ tile.resonantinduction\:fluidPipe.16.name=White Wood Trough
|
|||
## Machines and Processing
|
||||
tile.resonantinduction\:mixer.name=Mixer
|
||||
tile.resonantinduction\:mixer.tooltip=The mixer mixes dusts with water to wash and refine the ore dust. Mixer prefers more angular velocity (spin) to process dusts.
|
||||
tile.resonantinduction\:mechanicalPiston.name=Mechanical Piston
|
||||
tile.resonantinduction\:grindingWheel.name=Grinder Wheel
|
||||
tile.resonantinduction\:grindingWheel.tooltip=The grinding wheel grinds ores into rubble and dust. Larger torque allows faster grinding.
|
||||
tile.resonantinduction\:filter.name=Filter
|
||||
|
|
BIN
src/main/resources/assets/resonantinduction/models/rejector.tcn
Normal file
BIN
src/main/resources/assets/resonantinduction/models/rejector.tcn
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue