mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
little diesel guy
This commit is contained in:
parent
295d4c489a
commit
d787a9835c
@ -1837,7 +1837,7 @@ public class ModBlocks {
|
||||
machine_coal_off = new MachineCoal(false).setBlockName("machine_coal_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
machine_coal_on = new MachineCoal(true).setBlockName("machine_coal_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F);
|
||||
|
||||
machine_diesel = new MachineDiesel(Material.iron).setBlockName("machine_diesel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
machine_diesel = new MachineDiesel().setBlockName("machine_diesel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
machine_combustion_engine = new MachineCombustionEngine().setBlockName("machine_combustion_engine").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
|
||||
machine_shredder = new MachineShredder(Material.iron).setBlockName("machine_shredder").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
|
||||
@ -32,14 +32,11 @@ public abstract class BlockMachineBase extends BlockContainer {
|
||||
if(guiID == -1)
|
||||
return false;
|
||||
|
||||
if(world.isRemote)
|
||||
{
|
||||
if(world.isRemote) {
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
} else if(!player.isSneaking()) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, this.guiID, world, x, y, z);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -49,56 +46,56 @@ public abstract class BlockMachineBase extends BlockContainer {
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
|
||||
if (!keepInventory) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof ISidedInventory))
|
||||
return;
|
||||
|
||||
ISidedInventory tileentityfurnace = (ISidedInventory)te;
|
||||
|
||||
if (tileentityfurnace != null) {
|
||||
|
||||
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
|
||||
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
if(!keepInventory) {
|
||||
|
||||
if (itemstack != null) {
|
||||
|
||||
float f = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
while (itemstack.stackSize > 0) {
|
||||
|
||||
int j1 = world.rand.nextInt(21) + 10;
|
||||
if(!(te instanceof ISidedInventory))
|
||||
return;
|
||||
|
||||
if (j1 > itemstack.stackSize)
|
||||
j1 = itemstack.stackSize;
|
||||
ISidedInventory tileentityfurnace = (ISidedInventory) te;
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
if(tileentityfurnace != null) {
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)world.rand.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float)world.rand.nextGaussian() * f3;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
|
||||
world.func_147453_f(x, y, z, block);
|
||||
}
|
||||
}
|
||||
if(itemstack != null) {
|
||||
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
float f = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while(itemstack.stackSize > 0) {
|
||||
|
||||
int j1 = world.rand.nextInt(21) + 10;
|
||||
|
||||
if(j1 > itemstack.stackSize)
|
||||
j1 = itemstack.stackSize;
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
|
||||
if(itemstack.hasTagCompound())
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
|
||||
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
world.func_147453_f(x, y, z, block);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
@ -108,22 +105,9 @@ public abstract class BlockMachineBase extends BlockContainer {
|
||||
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
if(i == 1)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
}
|
||||
if(i == 2)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
if(i == 3)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,146 +1,44 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.fluid.trait.FT_Combustible.FuelGrade;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineDiesel;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineDiesel extends BlockContainer implements ITooltipProvider {
|
||||
public class MachineDiesel extends BlockMachineBase implements ITooltipProvider {
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private static boolean keepInventory;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconBottom;
|
||||
private IIcon iconTop;
|
||||
private IIcon iconSide;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":machine_diesel_bottom");
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":machine_diesel_top");
|
||||
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":machine_diesel_side");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_diesel_front");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if(side == 0) return iconBottom;
|
||||
if(side == 1) return iconTop;
|
||||
if(side == 2 || side == 3) return blockIcon;
|
||||
if(side == 4 || side == 5) return iconSide;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return Item.getItemFromBlock(ModBlocks.machine_diesel);
|
||||
}
|
||||
|
||||
public MachineDiesel(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
public MachineDiesel() {
|
||||
super(Material.iron, 0);
|
||||
this.rotatable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityMachineDiesel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote)
|
||||
{
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
TileEntityMachineDiesel entity = (TileEntityMachineDiesel) world.getTileEntity(x, y, z);
|
||||
if(entity != null)
|
||||
{
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public int getRenderType(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
|
||||
{
|
||||
if (!keepInventory)
|
||||
{
|
||||
TileEntityMachineDiesel tileentityfurnace = (TileEntityMachineDiesel)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
|
||||
|
||||
if (tileentityfurnace != null)
|
||||
{
|
||||
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
|
||||
{
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
int j1 = this.field_149933_a.nextInt(21) + 10;
|
||||
|
||||
if (j1 > itemstack.stackSize)
|
||||
{
|
||||
j1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
p_149749_1_.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
|
||||
}
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
|
||||
@ -259,6 +259,7 @@ public class ClientProxy extends ServerProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrucible.class, new RenderCrucible());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHeatBoiler.class, new RenderBoiler());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySteamEngine.class, new RenderSteamEngine());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineDiesel.class, new RenderDieselGen());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineCombustionEngine.class, new RenderCombustionEngine());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineExcavator.class, new RenderExcavator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineMixer.class, new RenderMixer());
|
||||
|
||||
@ -110,6 +110,7 @@ public class ResourceManager {
|
||||
public static final IModelCustom selenium_piston = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/selenium_engine_piston.obj"));
|
||||
|
||||
//Combustion Engine
|
||||
public static final IModelCustom dieselgen = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/dieselgen.obj"));
|
||||
public static final IModelCustom combustion_engine = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/combustion_engine.obj")).asDisplayList();
|
||||
|
||||
//Press
|
||||
@ -440,6 +441,7 @@ public class ResourceManager {
|
||||
public static final ResourceLocation selenium_rotor_tex = new ResourceLocation(RefStrings.MODID, "textures/models/selenium_engine_rotor.png");
|
||||
|
||||
//Combustion Engine
|
||||
public static final ResourceLocation dieselgen_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/dieselgen.png");
|
||||
public static final ResourceLocation combustion_engine_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/combustion_engine.png");
|
||||
|
||||
//Press
|
||||
|
||||
70
src/main/java/com/hbm/render/tileentity/RenderDieselGen.java
Normal file
70
src/main/java/com/hbm/render/tileentity/RenderDieselGen.java
Normal file
@ -0,0 +1,70 @@
|
||||
package com.hbm.render.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.item.ItemRenderBase;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineDiesel;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class RenderDieselGen extends TileEntitySpecialRenderer implements IItemRendererProvider {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
|
||||
switch(tile.getBlockMetadata()) {
|
||||
case 3: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
case 5: GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 2: GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 4: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.dieselgen_tex);
|
||||
|
||||
TileEntityMachineDiesel engine = (TileEntityMachineDiesel) tile;
|
||||
ResourceManager.dieselgen.renderPart("Generator");
|
||||
|
||||
if(engine.hasAcceptableFuel() && engine.tank.getFill() > 0) {
|
||||
double swingSide = Math.sin(System.currentTimeMillis() / 50D) * 0.005;
|
||||
double swingFront = Math.sin(System.currentTimeMillis() / 25D) * 0.005;
|
||||
GL11.glTranslated(swingFront, 0, swingSide);
|
||||
}
|
||||
|
||||
ResourceManager.dieselgen.renderPart("Engine");
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemForRenderer() {
|
||||
return Item.getItemFromBlock(ModBlocks.machine_diesel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRenderer getRenderer() {
|
||||
return new ItemRenderBase() {
|
||||
public void renderInventory() {
|
||||
GL11.glTranslated(0, -2.5, 0);
|
||||
double scale = 5;
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
}
|
||||
public void renderCommon() {
|
||||
GL11.glScaled(2, 2, 2);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.dieselgen_tex);
|
||||
ResourceManager.dieselgen.renderAll();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
}};
|
||||
}
|
||||
}
|
||||
@ -98,18 +98,22 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
|
||||
return p_94128_1_ == 0 ? slots_bottom : (p_94128_1_ == 1 ? slots_top : slots_side);
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return side == 0 ? slots_bottom : (side == 1 ? slots_top : slots_side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
|
||||
if (i == 1)
|
||||
if (itemStack.getItem() == ModItems.canister_empty || itemStack.getItem() == ModItems.tank_steel)
|
||||
public boolean canExtractItem(int i, ItemStack stack, int j) {
|
||||
if(i == 1) {
|
||||
if(stack.getItem() == ModItems.canister_empty || stack.getItem() == ModItems.tank_steel) {
|
||||
return true;
|
||||
if (i == 2)
|
||||
if (itemStack.getItem() instanceof IBatteryItem && ((IBatteryItem)itemStack.getItem()).getCharge(itemStack) == ((IBatteryItem)itemStack.getItem()).getMaxCharge())
|
||||
}
|
||||
}
|
||||
if(i == 2) {
|
||||
if(stack.getItem() instanceof IBatteryItem && ((IBatteryItem) stack.getItem()).getCharge(stack) == ((IBatteryItem) stack.getItem()).getMaxCharge()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -183,7 +187,7 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
|
||||
|
||||
public void generate() {
|
||||
|
||||
if (hasAcceptableFuel()) {
|
||||
if(hasAcceptableFuel()) {
|
||||
if (tank.getFill() > 0) {
|
||||
|
||||
if(!shutUp) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 521 B |
Loading…
x
Reference in New Issue
Block a user