mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
96 lines
2.9 KiB
Java
96 lines
2.9 KiB
Java
package com.hbm.blocks.machine;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import com.hbm.blocks.ILookOverlay;
|
|
import com.hbm.blocks.ITooltipProvider;
|
|
import com.hbm.inventory.fluid.FluidType;
|
|
import com.hbm.items.machine.IItemFluidIdentifier;
|
|
import com.hbm.tileentity.machine.TileEntityMachineAutosaw;
|
|
import com.hbm.util.I18nUtil;
|
|
|
|
import net.minecraft.block.BlockContainer;
|
|
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.util.ChatComponentText;
|
|
import net.minecraft.util.ChatComponentTranslation;
|
|
import net.minecraft.util.ChatStyle;
|
|
import net.minecraft.util.EnumChatFormatting;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
|
|
|
public class MachineAutosaw extends BlockContainer implements ILookOverlay, ITooltipProvider {
|
|
|
|
public MachineAutosaw() {
|
|
super(Material.iron);
|
|
}
|
|
|
|
@Override
|
|
public TileEntity createNewTileEntity(World world, int meta) {
|
|
return new TileEntityMachineAutosaw();
|
|
}
|
|
|
|
@Override
|
|
public int getRenderType() {
|
|
return -1;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean renderAsNormalBlock() {
|
|
return false;
|
|
}
|
|
|
|
@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 && !player.isSneaking()) {
|
|
|
|
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
|
|
|
|
TileEntityMachineAutosaw saw = (TileEntityMachineAutosaw) world.getTileEntity(x, y, z);
|
|
|
|
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, x, y, z, player.getHeldItem());
|
|
if(saw.acceptedFuels.contains(type)) {
|
|
saw.tank.setTankType(type);
|
|
saw.markDirty();
|
|
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
|
|
|
TileEntity te = world.getTileEntity(x, y, z);
|
|
|
|
if(!(te instanceof TileEntityMachineAutosaw))
|
|
return;
|
|
|
|
TileEntityMachineAutosaw saw = (TileEntityMachineAutosaw) te;
|
|
|
|
List<String> text = new ArrayList();
|
|
text.add(saw.tank.getTankType().getLocalizedName() + ": " + saw.tank.getFill() + "/" + saw.tank.getMaxFill() + "mB");
|
|
|
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
|
}
|
|
|
|
@Override
|
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
|
this.addStandardInfo(stack, player, list, ext);
|
|
}
|
|
}
|