Refueling Station! Refuels armor, attached armor mods, and any held items! Now Black Mesa themed!

This commit is contained in:
George Paton 2025-02-03 10:38:47 +11:00
parent 18af968073
commit a581cb74d0
11 changed files with 1487 additions and 0 deletions

View File

@ -603,6 +603,7 @@ public class ModBlocks {
public static Block spikes;
public static Block charger;
public static Block refueler;
public static Block tesla;
@ -2068,6 +2069,7 @@ public class ModBlocks {
spikes = new Spikes(Material.iron).setBlockName("spikes").setHardness(2.5F).setResistance(5.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":spikes");
charger = new Charger(Material.iron).setBlockName("charger").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
refueler = new BlockRefueler(Material.iron).setBlockName("refueler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
tesla = new MachineTesla(Material.iron).setBlockName("tesla").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":tesla");
@ -2709,6 +2711,7 @@ public class ModBlocks {
//Charger
GameRegistry.registerBlock(charger, charger.getUnlocalizedName());
GameRegistry.registerBlock(refueler, refueler.getUnlocalizedName());
//GameRegistry.registerBlock(floodlight, floodlight.getUnlocalizedName());
//Decoration Blocks

View File

@ -0,0 +1,101 @@
package com.hbm.blocks.machine;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.items.machine.IItemFluidIdentifier;
import com.hbm.tileentity.machine.TileEntityRefueler;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
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.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockRefueler extends BlockContainer {
public BlockRefueler(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityRefueler();
}
@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) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityRefueler))
return false;
TileEntityRefueler refueler = (TileEntityRefueler) te;
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, x, y, z, player.getHeldItem());
refueler.tank.setTankType(type);
refueler.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;
} else {
return true;
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
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);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.0625F;
switch(world.getBlockMetadata(x, y, z)) {
case 2: this.setBlockBounds(0F, 0F, 12 * f, 1F, 1F, 1F); break;
case 3: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 4 * f); break;
case 4: this.setBlockBounds(12 * f, 0F, 0F, 1F, 1F, 1F); break;
case 5: this.setBlockBounds(0F, 0F, 0F, 4 * f, 1F, 1F); break;
default: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F); break;
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBoundsBasedOnState(world, x, y, z);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}
}

View File

@ -376,6 +376,7 @@ public class ClientProxy extends ServerProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySubstation.class, new RenderSubstation());
//chargers
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCharger.class, new RenderCharger());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRefueler.class, new RenderRefueler());
//DecoContainer
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFileCabinet.class, new RenderFileCabinet());
//multiblocks
@ -1725,6 +1726,22 @@ public class ClientProxy extends ServerProxy {
}
}
if("fluidfill".equals(type)) {
double mX = data.getDouble("mX");
double mY = data.getDouble("mY");
double mZ = data.getDouble("mZ");
EntityFX fx = new net.minecraft.client.particle.EntityCritFX(world, x, y, z, mX, mY, mZ);
fx.nextTextureIndexX();
if(data.hasKey("color")) {
Color color = new Color(data.getInteger("color"));
fx.setRBGColorF(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
}
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
if("deadleaf".equals(type)) {
if(particleSetting == 0 || (particleSetting == 1 && rand.nextBoolean()))
Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleDeadLeaf(man, world, x, y, z));

View File

@ -11,6 +11,7 @@ import com.hbm.config.GeneralConfig;
import com.hbm.crafting.*;
import com.hbm.crafting.handlers.*;
import com.hbm.inventory.OreDictManager;
import com.hbm.inventory.OreDictManager.DictFrame;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.material.MaterialShapes;
import com.hbm.inventory.material.Mats;
@ -913,6 +914,7 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.charger), new Object[] { "G", "S", "C", 'G', Items.glowstone_dust, 'S', STEEL.ingot(), 'C', ModItems.coil_copper });
addRecipeAuto(new ItemStack(ModBlocks.charger, 16), new Object[] { "G", "S", "C", 'G', Blocks.glowstone, 'S', STEEL.block(), 'C', ModItems.coil_copper_torus });
addRecipeAuto(new ItemStack(ModBlocks.refueler), new Object[] { "SS", "HC", "SS", 'S', TI.plate(), 'H', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_HYDRAULIC), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC) });
addRecipeAuto(new ItemStack(ModBlocks.press_preheater), new Object[] { "CCC", "SLS", "TST", 'C', CU.plate(), 'S', Blocks.stone, 'L', Fluids.LAVA.getDict(1000), 'T', W.ingot() });
addRecipeAuto(new ItemStack(ModItems.fluid_identifier_multi), new Object[] { "D", "C", "P", 'D', "dye", 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ANALOG), 'P', IRON.plate() });

View File

@ -391,6 +391,7 @@ public class ResourceManager {
//Charging Station
public static final IModelCustom charger = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/blocks/charger.obj"));
public static final IModelCustom refueler = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/blocks/refueler.obj"));
//DecoContainer (File Cabinet for now)
public static final IModelCustom file_cabinet = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/file_cabinet.obj"));
@ -805,6 +806,7 @@ public class ResourceManager {
//Charger
public static final ResourceLocation charger_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/charger.png");
public static final ResourceLocation refueler_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/refueler.png");
//DecoContainer
public static final ResourceLocation file_cabinet_tex = new ResourceLocation(RefStrings.MODID, "textures/models/file_cabinet.png");

View File

@ -0,0 +1,103 @@
package com.hbm.render.tileentity;
import java.awt.Color;
import java.nio.DoubleBuffer;
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.TileEntityRefueler;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;
public class RenderRefueler extends TileEntitySpecialRenderer implements IItemRendererProvider {
private static DoubleBuffer clip = null;
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
TileEntityRefueler refueler = (TileEntityRefueler) tile;
GL11.glPushMatrix();
{
GL11.glTranslated(x + 0.5, y, z + 0.5);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glRotatef(90, 0F, 1F, 0F);
switch(tile.getBlockMetadata()) {
case 4: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 3: GL11.glRotatef(180, 0F, 1F, 0F); break;
case 5: GL11.glRotatef(270, 0F, 1F, 0F); break;
case 2: GL11.glRotatef(0, 0F, 1F, 0F); break;
}
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.refueler_tex);
ResourceManager.refueler.renderPart("Fueler");
if(clip == null) {
clip = GLAllocation.createDirectByteBuffer(8*4).asDoubleBuffer();
clip.put(new double[] {0, 1, 0, -0.125 });
clip.rewind();
}
GL11.glEnable(GL11.GL_CLIP_PLANE0);
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, clip);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
double fillLevel = refueler.prevFillLevel + (refueler.fillLevel - refueler.prevFillLevel) * interp;
GL11.glTranslated(0, (1 - fillLevel) * -0.625, 0);
Color color = new Color(refueler.tank.getTankType().getColor());
GL11.glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 0.75F);
ResourceManager.refueler.renderPart("Fluid");
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_CLIP_PLANE0);
GL11.glShadeModel(GL11.GL_FLAT);
}
GL11.glPopMatrix();
}
@Override
public Item getItemForRenderer() {
return Item.getItemFromBlock(ModBlocks.refueler);
}
@Override
public IItemRenderer getRenderer() {
return new ItemRenderBase() {
public void renderInventory() {
GL11.glTranslated(0, -3, 0);
GL11.glScaled(6, 6, 6);
}
public void renderCommon() {
GL11.glScaled(2, 2, 2);
GL11.glTranslated(0.5, 0, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.refueler_tex);
ResourceManager.refueler.renderPart("Fueler");
GL11.glShadeModel(GL11.GL_FLAT);
}
};
}
}

View File

@ -217,6 +217,7 @@ public class TileMappings {
put(TileEntityDoorGeneric.class, "tileentity_ntm_door");
put(TileEntityCharger.class, "tileentity_ntm_charger");
put(TileEntityRefueler.class, "tileentity_ntm_refueler");
put(TileEntityFileCabinet.class, "tileentity_file_cabinet");

View File

@ -0,0 +1,157 @@
package com.hbm.tileentity.machine;
import java.util.List;
import java.util.Random;
import com.hbm.handler.ArmorModHandler;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BobMathUtil;
import api.hbm.fluid.IFillableItem;
import api.hbm.fluid.IFluidStandardReceiver;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRefueler extends TileEntityLoadedBase implements IFluidStandardReceiver {
public double fillLevel;
public double prevFillLevel;
private boolean isOperating = false;
private int operatingTime;
public FluidTank tank;
public TileEntityRefueler() {
super();
tank = new FluidTank(Fluids.KEROSENE, 100);
}
@SuppressWarnings("unchecked")
@Override
public void updateEntity() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
if(!worldObj.isRemote) {
trySubscribe(tank.getTankType(), worldObj, xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ, dir);
isOperating = false;
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5, yCoord, zCoord + 0.5, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5).expand(0.5, 0.0, 0.5));
for(EntityPlayer player : players) {
for(int i = 0; i < 5; i++) {
ItemStack stack = player.getEquipmentInSlot(i);
if(stack == null) continue;
if(fillFillable(stack)) {
isOperating = true;
}
if(stack.getItem() instanceof ItemArmor && ArmorModHandler.hasMods(stack)) {
for(ItemStack mod : ArmorModHandler.pryMods(stack)) {
if(mod == null) continue;
if(fillFillable(mod)) {
ArmorModHandler.applyMod(stack, mod);
isOperating = true;
}
}
}
}
}
if(isOperating) {
if(operatingTime % 20 == 0)
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.fizz", 0.2F, 0.5F);
operatingTime++;
} else {
operatingTime = 0;
}
networkPackNT(150);
} else {
if(isOperating) {
Random rand = worldObj.rand;
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "fluidfill");
data.setInteger("color", tank.getTankType().getColor());
data.setDouble("posX", xCoord + 0.5 + rand.nextDouble() * 0.0625 + dir.offsetX * 0.5 + rot.offsetX * 0.25);
data.setDouble("posZ", zCoord + 0.5 + rand.nextDouble() * 0.0625 + dir.offsetZ * 0.5 + rot.offsetZ * 0.25);
data.setDouble("posY", yCoord + 0.375);
data.setDouble("mX", -dir.offsetX + rand.nextGaussian() * 0.1);
data.setDouble("mZ", -dir.offsetZ + rand.nextGaussian() * 0.1);
data.setDouble("mY", 0D);
MainRegistry.proxy.effectNT(data);
}
prevFillLevel = fillLevel;
double targetFill = (double)tank.getFill() / (double)tank.getMaxFill();
fillLevel = BobMathUtil.interp(fillLevel, targetFill, targetFill > fillLevel || !isOperating ? 0.1F : 0.01F);
}
}
private boolean fillFillable(ItemStack stack) {
if(stack.getItem() instanceof IFillableItem) {
IFillableItem fillable = (IFillableItem) stack.getItem();
if(fillable.acceptsFluid(tank.getTankType(), stack)) {
int prevFill = tank.getFill();
tank.setFill(fillable.tryFill(tank.getTankType(), tank.getFill(), stack));
return tank.getFill() < prevFill;
}
}
return false;
}
@Override
public void serialize(ByteBuf buf) {
buf.writeBoolean(isOperating);
tank.serialize(buf);
}
@Override
public void deserialize(ByteBuf buf) {
isOperating = buf.readBoolean();
tank.deserialize(buf);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
tank.readFromNBT(nbt, "t");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
tank.writeToNBT(nbt, "t");
}
@Override
public FluidTank[] getAllTanks() {
return new FluidTank[] { tank };
}
@Override
public FluidTank[] getReceivingTanks() {
return new FluidTank[] { tank };
}
}

View File

@ -5979,6 +5979,7 @@ tile.red_pylon_medium_steel_transformer.name=Medium Steel Electricity Pylon with
tile.red_pylon_medium_wood.name=Medium Wooden Electricity Pylon
tile.red_pylon_medium_wood_transformer.name=Medium Wooden Electricity Pylon with Transformer
tile.red_wire_coated.name=Coated Red Copper Cable
tile.refueler.name=Refueling Station
tile.reinforced_brick.name=Reinforced Stone
tile.reinforced_brick_stairs.name=Reinforced Stone Stairs
tile.reinforced_ducrete.name=Reinforced Ducrete

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB