Start work on Miner, make the Bin only eject items when front side is clicked!

This commit is contained in:
Aidan C. Brady 2013-11-18 15:33:14 -05:00
parent c1288c514e
commit 995207bcab
11 changed files with 99 additions and 233 deletions

View file

@ -68,6 +68,7 @@ import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityDynamicValve;
import mekanism.common.tileentity.TileEntityElectricChest;
@ -104,6 +105,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -226,7 +228,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityEnrichmentChamber.class, "EnrichmentChamber", new RenderConfigurableMachine());
ClientRegistry.registerTileEntity(TileEntityOsmiumCompressor.class, "OsmiumCompressor", new RenderConfigurableMachine());
ClientRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner", new RenderConfigurableMachine());
ClientRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher", new RenderConfigurableMachine()); //TODO model
ClientRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher", new RenderConfigurableMachine());
ClientRegistry.registerTileEntity(TileEntityFactory.class, "SmeltingFactory", new RenderConfigurableMachine());
ClientRegistry.registerTileEntity(TileEntityAdvancedFactory.class, "AdvancedSmeltingFactory", new RenderConfigurableMachine());
ClientRegistry.registerTileEntity(TileEntityEliteFactory.class, "UltimateSmeltingFactory", new RenderConfigurableMachine());
@ -247,6 +249,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter", new RenderLogisticalTransporter());
ClientRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter", new RenderLogisticalSorter());
ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin());
GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner"); //TODO model
}
@Override
@ -296,6 +299,8 @@ public class ClientProxy extends CommonProxy
{
case 1:
return new GuiCredits();
case 2:
//DigitalMiner GUI TODO
case 3:
return new GuiEnrichmentChamber(player.inventory, (TileEntityElectricMachine)tileEntity);
case 4:
@ -411,6 +416,12 @@ public class ClientProxy extends CommonProxy
}
}
@Override
public double getReach(EntityPlayer player)
{
return Minecraft.getMinecraft().playerController.getBlockReachDistance();
}
@Override
public boolean isPaused()
{

View file

@ -1,121 +0,0 @@
package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelCrusher extends ModelBase
{
ModelRenderer Top;
ModelRenderer Base;
ModelRenderer RightWall;
ModelRenderer RightWall2;
ModelRenderer PistonDecor;
ModelRenderer PistonRod;
ModelRenderer Pad;
ModelRenderer PistonHead;
ModelRenderer BackWall;
ModelRenderer BackWall2;
ModelRenderer TopTop;
public ModelCrusher()
{
textureWidth = 128;
textureHeight = 64;
Top = new ModelRenderer(this, 0, 18);
Top.addBox(0F, 0F, 0F, 14, 1, 8);
Top.setRotationPoint(-7F, 14F, -4F);
Top.setTextureSize(128, 64);
Top.mirror = true;
setRotation(Top, 0F, 0F, 0F);
Base = new ModelRenderer(this, 0, 0);
Base.addBox(0F, 0F, 0F, 16, 1, 16);
Base.setRotationPoint(-8F, 23F, -8F);
Base.setTextureSize(128, 64);
Base.mirror = true;
setRotation(Base, 0F, 0F, 0F);
RightWall = new ModelRenderer(this, 0, 28);
RightWall.addBox(0F, 0F, 0F, 4, 6, 14);
RightWall.setRotationPoint(-8F, 17F, -7F);
RightWall.setTextureSize(128, 64);
RightWall.mirror = true;
setRotation(RightWall, 0F, 0F, 0F);
RightWall2 = new ModelRenderer(this, 0, 49);
RightWall2.addBox(0F, 0F, 0F, 4, 2, 12);
RightWall2.setRotationPoint(-8F, 15F, -6F);
RightWall2.setTextureSize(128, 64);
RightWall2.mirror = true;
setRotation(RightWall2, 0F, 0F, 0F);
PistonDecor = new ModelRenderer(this, 65, 0);
PistonDecor.addBox(0F, 0F, 0F, 7, 1, 7);
PistonDecor.setRotationPoint(-0.5F, 14.5F, -3.5F);
PistonDecor.setTextureSize(128, 64);
PistonDecor.mirror = true;
setRotation(PistonDecor, 0F, 0F, 0F);
PistonRod = new ModelRenderer(this, 45, 18);
PistonRod.addBox(0F, 0F, 0F, 1, 6, 1);
PistonRod.setRotationPoint(2.5F, 13F, -0.5F);
PistonRod.setTextureSize(128, 64);
PistonRod.mirror = true;
setRotation(PistonRod, 0F, 0F, 0F);
Pad = new ModelRenderer(this, 50, 18);
Pad.addBox(0F, 0F, 0F, 4, 1, 4);
Pad.setRotationPoint(1F, 22.7F, -2F);
Pad.setTextureSize(128, 64);
Pad.mirror = true;
setRotation(Pad, 0F, 0F, 0F);
PistonHead = new ModelRenderer(this, 67, 18);
PistonHead.addBox(0F, 0F, 0F, 4, 1, 4);
PistonHead.setRotationPoint(1F, 19F, -2F);
PistonHead.setTextureSize(128, 64);
PistonHead.mirror = true;
setRotation(PistonHead, 0F, 0F, 0F);
BackWall = new ModelRenderer(this, 94, 0);
BackWall.addBox(0F, 0F, 0F, 11, 6, 2);
BackWall.setRotationPoint(-4F, 17F, 5F);
BackWall.setTextureSize(128, 64);
BackWall.mirror = true;
setRotation(BackWall, 0F, 0F, 0F);
BackWall2 = new ModelRenderer(this, 90, 9);
BackWall2.addBox(0F, 0F, 0F, 11, 2, 3);
BackWall2.setRotationPoint(-4F, 15F, 3F);
BackWall2.setTextureSize(128, 64);
BackWall2.mirror = true;
setRotation(BackWall2, 0F, 0F, 0F);
TopTop = new ModelRenderer(this, 90, 15);
TopTop.addBox(0F, 0F, 0F, 6, 5, 6);
TopTop.setRotationPoint(0F, 12F, -3F);
TopTop.setTextureSize(128, 64);
TopTop.mirror = true;
setRotation(TopTop, 0F, 0F, 0F);
}
public void render(float size, float depth)
{
PistonRod.setRotationPoint(2.5F, 13F+depth, -0.5F);
PistonHead.setRotationPoint(1F, 19F+depth, -2F);
Top.render(size);
Base.render(size);
RightWall.render(size);
RightWall2.render(size);
PistonDecor.render(size);
PistonRod.render(size);
Pad.render(size);
PistonHead.render(size);
BackWall.render(size);
BackWall2.render(size);
TopTop.render(size);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -2,12 +2,10 @@ package mekanism.client.render.block;
import mekanism.client.ClientProxy;
import mekanism.client.model.ModelChargepad;
import mekanism.client.model.ModelCrusher;
import mekanism.client.model.ModelElectricPump;
import mekanism.client.model.ModelLogisticalSorter;
import mekanism.client.model.ModelMetallurgicInfuser;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@ -29,7 +27,6 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler
public ModelMetallurgicInfuser metallurgicInfuser = new ModelMetallurgicInfuser();
public ModelChargepad chargepad = new ModelChargepad();
public ModelLogisticalSorter logisticalSorter = new ModelLogisticalSorter();
public ModelCrusher crusher = new ModelCrusher();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
@ -73,14 +70,6 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png"));
logisticalSorter.render(0.0625F, false);
}
/*else if(metadata == MachineType.CRUSHER.meta)
{
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F);
GL11.glTranslatef(0.0F, -1.0F, 0.0F);
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Crusher.png"));
crusher.render(0.0625F, 0.0F);
} TODO model */
else {
MekanismRenderer.renderItem(renderer, metadata, block);
}

View file

@ -1,44 +0,0 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelCrusher;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderCrusher extends TileEntitySpecialRenderer
{
private ModelCrusher model = new ModelCrusher();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityCrusher)tileEntity, x, y, z, partialTick);
}
private void renderAModelAt(TileEntityCrusher tileEntity, double x, double y, double z, float partialTick)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Crusher.png"));
switch(tileEntity.facing)
{
case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break;
case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break;
case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break;
case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break;
}
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F, tileEntity.isActive ? tileEntity.getMatrix() : 0.0F);
GL11.glPopMatrix();
}
}

View file

@ -25,6 +25,7 @@ import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityContainerBlock;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityDynamicValve;
import mekanism.common.tileentity.TileEntityElectricChest;
@ -46,6 +47,7 @@ import mekanism.common.tileentity.TileEntityPurificationChamber;
import mekanism.common.tileentity.TileEntityTeleporter;
import mekanism.common.tileentity.TileEntityUniversalCable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -89,6 +91,7 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter");
GameRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter");
GameRegistry.registerTileEntity(TileEntityBin.class, "Bin");
GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner");
}
/**
@ -240,6 +243,8 @@ public class CommonProxy
switch(ID)
{
case 2:
//DIGITAL MINER CONTAINER TODO
case 3:
return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine)tileEntity);
case 4:
@ -303,6 +308,16 @@ public class CommonProxy
return null;
}
public double getReach(EntityPlayer player)
{
if(player instanceof EntityPlayerMP)
{
return ((EntityPlayerMP)player).theItemInWorldManager.getBlockReachDistance();
}
return 0;
}
/**
* Gets the Minecraft base directory.
* @return base directory

View file

@ -39,6 +39,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import codechicken.lib.raytracer.RayTracer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -219,7 +220,10 @@ public class BlockBasic extends Block
if(!world.isRemote && meta == 6)
{
TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z);
MovingObjectPosition pos = MekanismUtils.rayTrace(world, player);
if(pos != null && pos.sideHit == bin.facing)
{
if(bin.getStack() != null)
{
if(!player.isSneaking())
@ -232,6 +236,7 @@ public class BlockBasic extends Block
}
}
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3)

View file

@ -31,6 +31,7 @@ import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityContainerBlock;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.tileentity.TileEntityElectricBlock;
import mekanism.common.tileentity.TileEntityElectricChest;
import mekanism.common.tileentity.TileEntityElectricPump;
@ -75,7 +76,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* 1: Osmium Compressor
* 2: Combiner
* 3: Crusher
* 4: OPEN
* 4: Digital Miner
* 5: Basic Factory
* 6: Advanced Factory
* 7: Elite Factory
@ -128,14 +129,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
icons[blockID][7][0] = register.registerIcon("mekanism:EliteFactoryFront");
icons[blockID][7][1] = register.registerIcon("mekanism:EliteFactorySide");
icons[blockID][7][2] = register.registerIcon("mekanism:EliteFactoryTop");
icons[blockID][8][0] = register.registerIcon("mekanism:MetallurgicInfuserFrontOff");
icons[blockID][8][1] = register.registerIcon("mekanism:MetallurgicInfuserFrontOn");
icons[blockID][8][2] = register.registerIcon("mekanism:MetallurgicInfuserSideOff");
icons[blockID][8][3] = register.registerIcon("mekanism:MetallurgicInfuserSideOn");
icons[blockID][8][4] = register.registerIcon("mekanism:MetallurgicInfuserTopOff");
icons[blockID][8][5] = register.registerIcon("mekanism:MetallurgicInfuserTopOn");
icons[blockID][8][6] = register.registerIcon("mekanism:MetallurgicInfuserBackOff");
icons[blockID][8][7] = register.registerIcon("mekanism:MetallurgicInfuserBackOn");
icons[blockID][9][0] = register.registerIcon("mekanism:PurificationChamberFrontOff");
icons[blockID][9][1] = register.registerIcon("mekanism:PurificationChamberFrontOn");
icons[blockID][9][2] = register.registerIcon("mekanism:SteelCasing");
@ -184,6 +177,19 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
}
}
@Override
public void breakBlock(World world, int x, int y, int z, int i1, int i2)
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof IBoundingBlock)
{
((IBoundingBlock)tileEntity).onBreak();
}
super.breakBlock(world, x, y, z, i1, i2);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
@ -332,24 +338,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
return icons[blockID][7][1];
}
}
else if(meta == 8)
{
if(side == 0 || side == 1)
{
return icons[blockID][8][4];
}
else if(side == 3)
{
return icons[blockID][8][0];
}
else if(side == 2)
{
return icons[blockID][8][6];
}
else {
return icons[blockID][8][2];
}
}
else if(meta == 9)
{
if(side == 3)
@ -468,26 +456,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
return icons[blockID][7][1];
}
}
else if(metadata == 8)
{
if(side == 0 || side == 1)
{
return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][8][5] : icons[blockID][8][4];
}
else {
if(side == tileEntity.facing)
{
return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][8][1] : icons[blockID][8][0];
}
else if(side == ForgeDirection.getOrientation(tileEntity.facing).getOpposite().ordinal())
{
return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][8][7] : icons[blockID][8][6];
}
else {
return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][8][3] : icons[blockID][8][2];
}
}
}
else if(metadata == 9)
{
if(side == tileEntity.facing)
@ -530,6 +498,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
list.add(new ItemStack(i, 1, 1));
list.add(new ItemStack(i, 1, 2));
list.add(new ItemStack(i, 1, 3));
//TODO DIGITAL MINER
for(RecipeType type : RecipeType.values())
{
@ -930,6 +899,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
OSMIUM_COMPRESSOR(Mekanism.machineBlockID, 1, "OsmiumCompressor", 4, Mekanism.osmiumCompressorUsage*400, TileEntityOsmiumCompressor.class, false),
COMBINER(Mekanism.machineBlockID, 2, "Combiner", 5, Mekanism.combinerUsage*400, TileEntityCombiner.class, false),
CRUSHER(Mekanism.machineBlockID, 3, "Crusher", 6, Mekanism.crusherUsage*400, TileEntityCrusher.class, false),
DIGITAL_MINER(Mekanism.machineBlockID, 4, "DigitalMiner", 2, 100000, TileEntityDigitalMiner.class, true),
BASIC_FACTORY(Mekanism.machineBlockID, 5, "BasicFactory", 11, Mekanism.factoryUsage*3*400, TileEntityFactory.class, false),
ADVANCED_FACTORY(Mekanism.machineBlockID, 6, "AdvancedFactory", 11, Mekanism.factoryUsage*5*400, TileEntityAdvancedFactory.class, false),
ELITE_FACTORY(Mekanism.machineBlockID, 7, "EliteFactory", 11, Mekanism.factoryUsage*7*400, TileEntityEliteFactory.class, false),

View file

@ -58,7 +58,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* 1: Osmium Compressor
* 2: Combiner
* 3: Crusher
* 4: OPEN
* 4: Digital Miner
* 5: Basic Factory
* 6: Advanced Factory
* 7: Elite Factory

View file

@ -0,0 +1,11 @@
package mekanism.common.tileentity;
import mekanism.common.block.BlockMachine.MachineType;
public class TileEntityDigitalMiner extends TileEntityElectricBlock
{
public TileEntityDigitalMiner()
{
super("Digital Miner", MachineType.DIGITAL_MINER.baseEnergy);
}
}

View file

@ -41,13 +41,14 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.network.packet.Packet3Chat;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -1028,6 +1029,34 @@ public final class MekanismUtils
return false;
}
public static MovingObjectPosition rayTrace(World world, EntityPlayer player)
{
double reach = Mekanism.proxy.getReach(player);
Vec3 headVec = getHeadVec(player);
Vec3 lookVec = player.getLook(1);
Vec3 endVec = headVec.addVector(lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach);
return world.rayTraceBlocks_do_do(headVec, endVec, true, false);
}
public static Vec3 getHeadVec(EntityPlayer player)
{
Vec3 vec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
if(!player.worldObj.isRemote)
{
vec.yCoord+=player.getEyeHeight();
if(player instanceof EntityPlayerMP && player.isSneaking())
{
vec.yCoord-=0.08;
}
}
return vec;
}
public static boolean useBuildcraft()
{
return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft;

View file

@ -55,6 +55,7 @@ tile.MachineBlock.ElectricPump.name=Electric Pump
tile.MachineBlock.ElectricChest.name=Electric Chest
tile.MachineBlock.Chargepad.name=Chargepad
tile.MachineBlock.LogisticalSorter.name=Logistical Sorter
tile.MachineBlock.DigitalMiner.name=Digital Miner
//Ore Block
tile.OreBlock.OsmiumOre.name=Osmium Ore