Fixed grinding wheel render
This commit is contained in:
parent
60f13cabe8
commit
625f795eac
4 changed files with 66 additions and 118 deletions
|
@ -29,8 +29,7 @@ import resonantinduction.mechanical.logistic.belt.TileDetector;
|
|||
import resonantinduction.mechanical.logistic.belt.TileManipulator;
|
||||
import resonantinduction.mechanical.logistic.belt.TileSorter;
|
||||
import resonantinduction.mechanical.process.crusher.TileMechanicalPiston;
|
||||
import resonantinduction.mechanical.process.grinder.BlockGrindingWheel;
|
||||
import resonantinduction.mechanical.process.grinder.TileGrinderWheel;
|
||||
import resonantinduction.mechanical.process.grinder.TileGrindingWheel;
|
||||
import resonantinduction.mechanical.process.purifier.BlockMixer;
|
||||
import resonantinduction.mechanical.process.purifier.TileMixer;
|
||||
import calclavia.components.creative.BlockCreativeBuilder;
|
||||
|
@ -123,7 +122,7 @@ public class Mechanical
|
|||
itemPipe = contentRegistry.createItem(ItemPipe.class);
|
||||
|
||||
// Machines
|
||||
blockGrinderWheel = contentRegistry.createTile(BlockGrindingWheel.class, TileGrinderWheel.class);
|
||||
blockGrinderWheel = contentRegistry.newBlock(TileGrindingWheel.class);
|
||||
blockPurifier = contentRegistry.createTile(BlockMixer.class, TileMixer.class);
|
||||
blockMechanicalPiston = contentRegistry.newBlock(TileMechanicalPiston.class);
|
||||
OreDictionary.registerOre("gear", itemGear);
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
package resonantinduction.mechanical.process.grinder;
|
||||
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.Reference;
|
||||
import calclavia.lib.prefab.block.BlockRotatable;
|
||||
import calclavia.lib.render.block.BlockRenderingHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A block used to build machines.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockGrindingWheel extends BlockRotatable implements ITileEntityProvider
|
||||
{
|
||||
public BlockGrindingWheel(int id)
|
||||
{
|
||||
super(id, Material.wood);
|
||||
setTextureName(Reference.PREFIX + "material_steel_dark");
|
||||
setBlockBounds(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f);
|
||||
rotationMask = Byte.parseByte("111111", 2);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockRenderingHandler.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
((EntityItem) entity).age--;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity instanceof TileGrinderWheel)
|
||||
{
|
||||
TileGrinderWheel tile = (TileGrinderWheel) tileEntity;
|
||||
|
||||
if (tile.canWork())
|
||||
{
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
if (tile.canGrind(((EntityItem) entity).getEntityItem()))
|
||||
{
|
||||
if (tile.grindingItem == null)
|
||||
{
|
||||
tile.grindingItem = (EntityItem) entity;
|
||||
}
|
||||
|
||||
if (!TileGrinderWheel.timer.containsKey((EntityItem) entity))
|
||||
{
|
||||
TileGrinderWheel.timer.put((EntityItem) entity, TileGrinderWheel.PROCESS_TIME);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.setPosition(entity.posX, entity.posY - 1.2, entity.posZ);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.attackEntityFrom(DamageSource.cactus, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (tile.mechanicalNode.getAngularVelocity() != 0)
|
||||
{
|
||||
// Move entity based on the direction of the block.
|
||||
ForgeDirection dir = this.getDirection(world, x, y, z);
|
||||
dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal()).getOpposite();
|
||||
double speed = tile.mechanicalNode.getAngularVelocity() / 20;
|
||||
entity.addVelocity(dir.offsetX * speed, Math.random() * speed, dir.offsetZ * speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileGrinderWheel();
|
||||
}
|
||||
}
|
|
@ -20,16 +20,16 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderGrinderWheel extends TileEntitySpecialRenderer
|
||||
public class RenderGrindingWheel extends TileEntitySpecialRenderer
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (t instanceof TileGrinderWheel)
|
||||
if (t instanceof TileGrindingWheel)
|
||||
{
|
||||
TileGrinderWheel tile = (TileGrinderWheel) t;
|
||||
TileGrindingWheel tile = (TileGrindingWheel) t;
|
||||
glPushMatrix();
|
||||
glTranslatef((float) x + 0.5F, (float) y + 0.5f, (float) z + 0.5F);
|
||||
glScalef(0.51f, 0.5f, 0.5f);
|
|
@ -1,8 +1,11 @@
|
|||
package resonantinduction.mechanical.process.grinder;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -17,12 +20,13 @@ import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
|||
import resonantinduction.mechanical.energy.grid.TileMechanical;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.prefab.vector.Cuboid;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileGrinderWheel extends TileMechanical implements IRotatable
|
||||
public class TileGrindingWheel extends TileMechanical implements IRotatable
|
||||
{
|
||||
public static final int PROCESS_TIME = 20 * 20;
|
||||
/** A map of ItemStacks and their remaining grind-time left. */
|
||||
|
@ -33,8 +37,10 @@ public class TileGrinderWheel extends TileMechanical implements IRotatable
|
|||
private final long requiredTorque = 1000;
|
||||
private double counter = 0;
|
||||
|
||||
public TileGrinderWheel()
|
||||
public TileGrindingWheel()
|
||||
{
|
||||
super(Material.rock);
|
||||
|
||||
mechanicalNode = new PacketMechanicalNode(this)
|
||||
{
|
||||
@Override
|
||||
|
@ -54,6 +60,59 @@ public class TileGrinderWheel extends TileMechanical implements IRotatable
|
|||
return !(dir.offsetX > 0 || dir.offsetZ < 0 || dir.offsetY < 0);
|
||||
}
|
||||
}.setLoad(2);
|
||||
|
||||
bounds = new Cuboid(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f);
|
||||
isOpaqueCube = false;
|
||||
normalRender = false;
|
||||
customItemRender = true;
|
||||
rotationMask = Byte.parseByte("111111", 2);
|
||||
textureName = "material_steel_dark";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
((EntityItem) entity).age--;
|
||||
}
|
||||
|
||||
if (canWork())
|
||||
{
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
if (canGrind(((EntityItem) entity).getEntityItem()))
|
||||
{
|
||||
if (grindingItem == null)
|
||||
{
|
||||
grindingItem = (EntityItem) entity;
|
||||
}
|
||||
|
||||
if (!TileGrindingWheel.timer.containsKey((EntityItem) entity))
|
||||
{
|
||||
TileGrindingWheel.timer.put((EntityItem) entity, TileGrindingWheel.PROCESS_TIME);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.setPosition(entity.posX, entity.posY - 1.2, entity.posZ);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.attackEntityFrom(DamageSource.cactus, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (mechanicalNode.getAngularVelocity() != 0)
|
||||
{
|
||||
// Move entity based on the direction of the block.
|
||||
ForgeDirection dir = getDirection();
|
||||
dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal()).getOpposite();
|
||||
double speed = mechanicalNode.getAngularVelocity() / 20;
|
||||
entity.addVelocity(dir.offsetX * speed, Math.random() * speed, dir.offsetZ * speed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
Loading…
Reference in a new issue