This commit is contained in:
JameH2 2023-11-06 14:02:08 -07:00
parent 98b05b1c70
commit 1e43e00b33
3 changed files with 85 additions and 3 deletions

View File

@ -27,6 +27,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -71,7 +74,19 @@ public class BlockFluidBarrel extends BlockContainer implements ITooltipProvider
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
} else {
} else if(player.isSneaking()){
TileEntityBarrel mileEntity = (TileEntityBarrel) world.getTileEntity(x, y, z);
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, x, y, z, player.getHeldItem());
mileEntity.tank.setTankType(type);
mileEntity.markDirty();
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
}
return true;
}else {
return false;
}
}

View File

@ -7,9 +7,11 @@ import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.IPersistentInfoProvider;
import com.hbm.entity.projectile.EntityBombletZeta;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.fluid.trait.FT_Flammable;
import com.hbm.items.machine.IItemFluidIdentifier;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IPersistentNBT;
import com.hbm.tileentity.IRepairable;
@ -27,6 +29,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
@ -61,7 +66,8 @@ public class MachineFluidTank extends BlockDummyable implements IPersistentInfoP
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
}
else if(!player.isSneaking()) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
@ -74,9 +80,30 @@ public class MachineFluidTank extends BlockDummyable implements IPersistentInfoP
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]);
}
return true;
} else {
}
else if(player.isSneaking()){
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
TileEntityMachineFluidTank tank = (TileEntityMachineFluidTank) world.getTileEntity(pos[0], pos[1], pos[2]);
if(tank != null) {
if(tank.hasExploded) return false;
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, pos[0], pos[1], pos[2], player.getHeldItem());
tank.tank.setTankType(type);
tank.markDirty();
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
}
}
return true;
}else {
return true;
}
}
@Override

View File

@ -5,8 +5,10 @@ import java.util.List;
import com.hbm.blocks.IBlockMulti;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.test.TestPipe;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.items.ModItems;
import com.hbm.lib.Library;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.network.TileEntityPipeBaseNT;
@ -14,15 +16,18 @@ import com.hbm.util.I18nUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
@ -70,7 +75,42 @@ public class FluidDuctStandard extends FluidDuctBase implements IBlockMulti, ILo
public int damageDropped(int meta) {
return rectify(meta);
}
/*
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z); // Get the block at the specified coordinates
int blockMetadata = world.getBlockMetadata(x, y, z); // Get the metadata of the block at the specified coordinates
TileEntity tileEntity = world.getTileEntity(x, y, z); // Get the tile entity at the specified coordinates
TileEntityPipeBaseNT pipe = (TileEntityPipeBaseNT) tileEntity;
// Get the metadata (FluidType) from the pipe
FluidType fluidType = pipe.getType();
int metadata = fluidType.getID();
// Create an ItemStack with the item and metadata
ItemStack itemStack = new ItemStack(ModItems.fluid_duct, 1, metadata);
System.out.println(metadata);
System.out.println(itemStack);
return new ItemStack(ModItems.fluid_duct, 1, metadata).getItem();
}
*/
@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityPipeBaseNT) {
TileEntityPipeBaseNT pipe = (TileEntityPipeBaseNT) tileEntity;
FluidType fluidType = pipe.getType();
int retadata = fluidType.getID(); //florf
return new ItemStack(ModItems.fluid_duct, 1, retadata);
}
return super.getPickBlock(target, world, x, y, z, player);
}
@Override
public int getRenderType() {
return TestPipe.renderID;