added efficiency tooltips to combustion engine blocks

This commit is contained in:
Boblet 2022-02-14 09:27:18 +01:00
parent 91ba3d704c
commit bdb012d11b
9 changed files with 124 additions and 95 deletions

View File

@ -2819,8 +2819,8 @@ public class ModBlocks {
GameRegistry.registerBlock(machine_rtg_furnace_on, machine_rtg_furnace_on.getUnlocalizedName());
GameRegistry.registerBlock(machine_coal_off, machine_coal_off.getUnlocalizedName());
GameRegistry.registerBlock(machine_coal_on, machine_coal_on.getUnlocalizedName());
GameRegistry.registerBlock(machine_diesel, machine_diesel.getUnlocalizedName());
GameRegistry.registerBlock(machine_selenium, machine_selenium.getUnlocalizedName());
GameRegistry.registerBlock(machine_diesel, ItemBlockBase.class, machine_diesel.getUnlocalizedName());
GameRegistry.registerBlock(machine_selenium, ItemBlockBase.class, machine_selenium.getUnlocalizedName());
GameRegistry.registerBlock(machine_generator, machine_generator.getUnlocalizedName());
GameRegistry.registerBlock(machine_controller, machine_controller.getUnlocalizedName());
GameRegistry.registerBlock(reactor_research, reactor_research.getUnlocalizedName());
@ -2976,9 +2976,9 @@ public class ModBlocks {
GameRegistry.registerBlock(fraction_spacer, fraction_spacer.getUnlocalizedName());
GameRegistry.registerBlock(machine_catalytic_cracker, machine_catalytic_cracker.getUnlocalizedName());
GameRegistry.registerBlock(machine_drill, machine_drill.getUnlocalizedName());
GameRegistry.registerBlock(machine_mining_laser, ItemBlockLore.class, machine_mining_laser.getUnlocalizedName());
GameRegistry.registerBlock(machine_mining_laser, ItemBlockBase.class, machine_mining_laser.getUnlocalizedName());
GameRegistry.registerBlock(barricade, barricade.getUnlocalizedName());
GameRegistry.registerBlock(machine_turbofan, machine_turbofan.getUnlocalizedName());
GameRegistry.registerBlock(machine_turbofan, ItemBlockBase.class, machine_turbofan.getUnlocalizedName());
GameRegistry.registerBlock(machine_schrabidium_transmutator, machine_schrabidium_transmutator.getUnlocalizedName());
GameRegistry.registerBlock(machine_combine_factory, machine_combine_factory.getUnlocalizedName());
GameRegistry.registerBlock(machine_teleporter, machine_teleporter.getUnlocalizedName());

View File

@ -1,8 +1,11 @@
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.FluidTypeCombustible.FuelGrade;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityMachineDiesel;
@ -20,13 +23,13 @@ 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 {
public class MachineDiesel extends BlockContainer implements ITooltipProvider {
private final Random field_149933_a = new Random();
private Random rand;
private static boolean keepInventory;
@SideOnly(Side.CLIENT)
@ -46,14 +49,10 @@ public class MachineDiesel extends BlockContainer {
@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;
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;
}
@ -143,4 +142,17 @@ public class MachineDiesel extends BlockContainer {
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add(EnumChatFormatting.YELLOW + "Fuel efficiency:");
for(FuelGrade grade : FuelGrade.values()) {
Double efficiency = TileEntityMachineDiesel.fuelEfficiency.get(grade);
if(efficiency != null) {
int eff = (int)(efficiency * 100);
list.add(EnumChatFormatting.YELLOW + "-" + grade.getGrade() + ": " + EnumChatFormatting.RED + "" + eff + "%");
}
}
}
}

View File

@ -1,6 +1,9 @@
package com.hbm.blocks.machine;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityProxyEnergy;
@ -10,11 +13,12 @@ import com.hbm.tileentity.machine.TileEntityMachineMiningLaser;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineMiningLaser extends BlockDummyable {
public class MachineMiningLaser extends BlockDummyable implements ITooltipProvider {
public MachineMiningLaser(Material mat) {
super(mat);
@ -83,4 +87,10 @@ public class MachineMiningLaser extends BlockDummyable {
this.makeExtra(world, x, y + 1, z);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add("3x3x3 Multiblock");
list.add("Only placeable on a ceiling.");
}
}

View File

@ -1,8 +1,11 @@
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.FluidTypeCombustible.FuelGrade;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine;
@ -16,14 +19,14 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class MachineSeleniumEngine extends BlockContainer {
private final Random field_149933_a = new Random();
private static boolean keepInventory;
public class MachineSeleniumEngine extends BlockContainer implements ITooltipProvider {
private final Random field_149933_a = new Random();
private static boolean keepInventory;
public MachineSeleniumEngine(Material p_i45386_1_) {
super(p_i45386_1_);
@ -48,91 +51,76 @@ public class MachineSeleniumEngine extends BlockContainer {
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(i == 0)
{
if(i == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(i == 1)
{
if(i == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(i == 2)
{
if(i == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(i == 3)
{
if(i == 3) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
@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)
{
TileEntityMachineSeleniumEngine tileentityfurnace = (TileEntityMachineSeleniumEngine)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
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) {
TileEntityMachineSeleniumEngine tileentityfurnace = (TileEntityMachineSeleniumEngine) 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(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;
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;
while(itemstack.stackSize > 0) {
int j1 = this.field_149933_a.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
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()));
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());
}
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);
}
}
}
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_);
}
}
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_);
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@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)
{
if(world.isRemote) {
return true;
} else if(!player.isSneaking())
{
} else if(!player.isSneaking()) {
TileEntityMachineSeleniumEngine entity = (TileEntityMachineSeleniumEngine) world.getTileEntity(x, y, z);
if(entity != null)
{
if(entity != null) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_selenium, world, x, y, z);
}
return true;
@ -141,4 +129,17 @@ public class MachineSeleniumEngine extends BlockContainer {
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add(EnumChatFormatting.YELLOW + "Fuel efficiency:");
for(FuelGrade grade : FuelGrade.values()) {
Double efficiency = TileEntityMachineSeleniumEngine.fuelEfficiency.get(grade);
if(efficiency != null) {
int eff = (int) (efficiency * 100);
list.add(EnumChatFormatting.YELLOW + "-" + grade.getGrade() + ": " + EnumChatFormatting.RED + "" + eff + "%");
}
}
}
}

View File

@ -1,13 +1,17 @@
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.handler.MultiblockHandler;
import com.hbm.interfaces.IMultiblock;
import com.hbm.inventory.fluid.FluidTypeCombustible.FuelGrade;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityDummy;
import com.hbm.tileentity.machine.TileEntityMachineDiesel;
import com.hbm.tileentity.machine.TileEntityMachineTurbofan;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
@ -22,10 +26,11 @@ 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.MathHelper;
import net.minecraft.world.World;
public class MachineTurbofan extends BlockContainer implements IMultiblock {
public class MachineTurbofan extends BlockContainer implements IMultiblock, ITooltipProvider {
public MachineTurbofan(Material p_i45386_1_) {
super(p_i45386_1_);
@ -316,4 +321,11 @@ public class MachineTurbofan extends BlockContainer implements IMultiblock {
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add(EnumChatFormatting.YELLOW + "Fuel efficiency:");
list.add(EnumChatFormatting.YELLOW + "-" + FuelGrade.AERO.getGrade() + ": " + EnumChatFormatting.RED + "100%");
}
}

View File

@ -78,11 +78,6 @@ public class ItemBlockLore extends ItemBlock {
list.add("Come on, get a derrick you doofus.");
}
if(this.field_150939_a == ModBlocks.machine_mining_laser) {
list.add("3x3x3 Multiblock");
list.add("Only placeable on a ceiling.");
}
if(this.field_150939_a == ModBlocks.gravel_diamond) {
list.add("There is some kind of joke here,");
list.add("but I can't quite tell what it is.");

View File

@ -139,8 +139,7 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
public static HashMap<FuelGrade, Double> fuelEfficiency = new HashMap();
static {
fuelEfficiency.put(FuelGrade.LOW, 0.5D);
fuelEfficiency.put(FuelGrade.MEDIUM, 1.0D);
fuelEfficiency.put(FuelGrade.MEDIUM, 0.9D);
fuelEfficiency.put(FuelGrade.HIGH, 1.0D);
fuelEfficiency.put(FuelGrade.AERO, 0.1D);
}
@ -217,17 +216,17 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
@Override
public int getMaxFluidFill(FluidType type) {
return type.name().equals(this.tank.getTankType().name()) ? tank.getMaxFill() : 0;
return type == this.tank.getTankType() ? tank.getMaxFill() : 0;
}
@Override
public int getFluidFill(FluidType type) {
return type.name().equals(this.tank.getTankType().name()) ? tank.getFill() : 0;
return type == this.tank.getTankType() ? tank.getFill() : 0;
}
@Override
public void setFluidFill(int i, FluidType type) {
if(type.name().equals(tank.getTankType().name()))
if(type == tank.getTankType())
tank.setFill(i);
}

View File

@ -337,17 +337,17 @@ public class TileEntityMachineSeleniumEngine extends TileEntity implements ISide
@Override
public int getMaxFluidFill(FluidType type) {
return type.name().equals(this.tank.getTankType().name()) ? tank.getMaxFill() : 0;
return type == this.tank.getTankType() ? tank.getMaxFill() : 0;
}
@Override
public int getFluidFill(FluidType type) {
return type.name().equals(this.tank.getTankType().name()) ? tank.getFill() : 0;
return type == this.tank.getTankType() ? tank.getFill() : 0;
}
@Override
public void setFluidFill(int i, FluidType type) {
if(type.name().equals(tank.getTankType().name()))
if(type == tank.getTankType())
tank.setFill(i);
}

View File

@ -508,17 +508,17 @@ public class TileEntityMachineTurbofan extends TileEntity implements ISidedInven
@Override
public int getMaxFluidFill(FluidType type) {
return type.name().equals(this.tank.getTankType().name()) ? tank.getMaxFill() : 0;
return type == this.tank.getTankType() ? tank.getMaxFill() : 0;
}
@Override
public int getFluidFill(FluidType type) {
return type.name().equals(this.tank.getTankType().name()) ? tank.getFill() : 0;
return type == this.tank.getTankType() ? tank.getFill() : 0;
}
@Override
public void setFluidFill(int i, FluidType type) {
if(type.name().equals(tank.getTankType().name()))
if(type == tank.getTankType())
tank.setFill(i);
}