Merge pull request #1125 from sdddddf80/Custom-machine-structure-display

Add structure display for custom machine
This commit is contained in:
HbmMods 2023-07-25 22:06:03 +02:00 committed by GitHub
commit 244fbacd39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 4 deletions

View File

@ -2027,7 +2027,7 @@ public class ModBlocks {
cm_tank = new BlockCMGlass(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_tank").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_tank");
cm_circuit = new BlockCM(Material.iron, EnumCMCircuit.class, true, true).setBlockName("cm_circuit").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_circuit");
cm_port = new BlockCMPort(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_port").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_port");
custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F);
custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.machineTab).setLightLevel(1F).setHardness(5.0F).setResistance(10.0F);
reactor_element = new BlockPillar(Material.iron, RefStrings.MODID + ":reactor_element_top", RefStrings.MODID + ":reactor_element_base").setBlockName("reactor_element").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":reactor_element_side");
reactor_control = new BlockPillar(Material.iron, RefStrings.MODID + ":reactor_control_top").setBlockName("reactor_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":reactor_control_side");

View File

@ -203,9 +203,9 @@ public class CustomMachineConfigJSON {
compDef.y = compObject.get("y").getAsInt();
compDef.z = compObject.get("z").getAsInt();
compDef.allowedMetas = new HashSet();
JsonArray metas = compObject.get("metas").getAsJsonArray();
for(int k = 0; k < metas.size(); k++) {
compDef.allowedMetas.add(metas.get(k).getAsInt());
compDef.metas = compObject.get("metas").getAsJsonArray();
for(int k = 0; k < compDef.metas.size(); k++) {
compDef.allowedMetas.add(compDef.metas.get(k).getAsInt());
}
configuration.components.add(compDef);
@ -248,6 +248,7 @@ public class CustomMachineConfigJSON {
public static class ComponentDefinition {
public Block block;
public Set<Integer> allowedMetas;
public JsonArray metas;
public int x;
public int y;
public int z;

View File

@ -325,6 +325,7 @@ public class ClientProxy extends ServerProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityITERStruct.class, new RenderITERMultiblock());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPlasmaStruct.class, new RenderPlasmaMultiblock());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWatzStruct.class, new RenderWatzMultiblock());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCustomMachine.class, new RenderCustomMachine());
//RBMK
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKControlManual.class, new RenderRBMKControlRod());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKControlAuto.class, new RenderRBMKControlRod());

View File

@ -0,0 +1,44 @@
package com.hbm.render.tileentity;
import com.hbm.config.CustomMachineConfigJSON;
import com.hbm.render.util.SmallBlockPronter;
import com.hbm.tileentity.machine.TileEntityCustomMachine;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class RenderCustomMachine extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
NBTTagCompound nbt = new NBTTagCompound();
tile.writeToNBT(nbt);
CustomMachineConfigJSON.MachineConfiguration config = CustomMachineConfigJSON.customMachines.get(nbt.getString("machineType"));
ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata());
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
bindTexture(TextureMap.locationBlocksTexture);
SmallBlockPronter.startDrawing();
for(CustomMachineConfigJSON.MachineConfiguration.ComponentDefinition comp : config.components){
int rx = - dir.offsetX * comp.x + rot.offsetX * comp.x;
int ry = + comp.y;
int rz = - dir.offsetZ * comp.z + rot.offsetZ * comp.z;
if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
rx = + dir.offsetZ * comp.z - rot.offsetZ * comp.z;
rz = + dir.offsetX * comp.x - rot.offsetX * comp.x;
}
SmallBlockPronter.drawSmolBlockAt(comp.block,comp.metas.get(comp.metas.size()-1).getAsInt(),rx,ry,rz);
}
SmallBlockPronter.draw();
GL11.glPopMatrix();
}
}