mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2407 from MellowArpeggiation/inventory-pronter
PWR printing tool
This commit is contained in:
commit
53a63a28aa
@ -4,6 +4,7 @@ import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR;
|
||||
import com.hbm.handler.threading.PacketThreading;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||
@ -55,7 +56,7 @@ public class MachinePWRController extends BlockContainer implements ITooltipProv
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
|
||||
return metadata == 0 && side != 0 && side != 1 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,6 +81,7 @@ public class MachinePWRController extends BlockContainer implements ITooltipProv
|
||||
if(!controller.assembled) {
|
||||
assemble(world, x, y, z, player);
|
||||
} else {
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.pwr_printer) return false;
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
144
src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java
Normal file
144
src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java
Normal file
@ -0,0 +1,144 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.machine.BlockPWR;
|
||||
import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class GUIScreenSlicePrinter extends GuiScreen {
|
||||
|
||||
private final int x1, y1, z1;
|
||||
private final int x2, y2, z2;
|
||||
private final int sizeX, sizeY, sizeZ;
|
||||
private final ForgeDirection dir;
|
||||
|
||||
private HashSet<Block> whitelist;
|
||||
|
||||
private int yIndex;
|
||||
|
||||
private RenderBlocks renderer;
|
||||
|
||||
private String dirname;
|
||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
|
||||
|
||||
public GUIScreenSlicePrinter(int x1, int y1, int z1, int x2, int y2, int z2, ForgeDirection dir) {
|
||||
this.x1 = Math.min(x1, x2);
|
||||
this.y1 = Math.min(y1, y2);
|
||||
this.z1 = Math.min(z1, z2);
|
||||
this.x2 = Math.max(x1, x2);
|
||||
this.y2 = Math.max(y1, y2);
|
||||
this.z2 = Math.max(z1, z2);
|
||||
|
||||
this.dir = dir;
|
||||
|
||||
this.sizeX = this.x2 - this.x1 + 1;
|
||||
this.sizeY = this.y2 - this.y1 + 1;
|
||||
this.sizeZ = this.z2 - this.z1 + 1;
|
||||
|
||||
dirname = dateFormat.format(new Date()).toString();
|
||||
}
|
||||
|
||||
public GUIScreenSlicePrinter(int x1, int y1, int z1, int x2, int y2, int z2, ForgeDirection dir, HashSet<Block> whitelist) {
|
||||
this(x1, y1, z1, x2, y2, z2, dir);
|
||||
this.whitelist = whitelist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
if(renderer == null) {
|
||||
this.renderer = new RenderBlocks(mc.theWorld);
|
||||
}
|
||||
|
||||
GuiScreen.drawRect(0, 0, width, height, 0xFFFF00FF);
|
||||
|
||||
// Once we've reached the top slice, close the GUI
|
||||
if(yIndex >= sizeY) {
|
||||
mc.thePlayer.addChatMessage(new ChatComponentText("Slices saved to: .minecraft/printer/" + dirname));
|
||||
mc.thePlayer.closeScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
{
|
||||
|
||||
setupRotation();
|
||||
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
|
||||
for(int x = 0; x < sizeX; x++) {
|
||||
for(int z = 0; z < sizeZ; z++) {
|
||||
Block block = mc.theWorld.getBlock(x1 + x, y1 + yIndex, z1 + z);
|
||||
if(whitelist != null && !whitelist.contains(block)) continue;
|
||||
|
||||
// Revert PWR blocks to originals for slice rendering
|
||||
if(block instanceof BlockPWR) {
|
||||
TileEntity tile = mc.theWorld.getTileEntity(x1 + x, y1 + yIndex, z1 + z);
|
||||
if(tile instanceof TileEntityBlockPWR) {
|
||||
TileEntityBlockPWR pwr = (TileEntityBlockPWR) tile;
|
||||
if(pwr.block != null) {
|
||||
block = pwr.block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderer.renderBlockByRenderType(block, x, 0, z);
|
||||
}
|
||||
}
|
||||
|
||||
Tessellator.instance.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
File printerDir = new File(mc.mcDataDir, "printer");
|
||||
printerDir.mkdir();
|
||||
|
||||
GUIScreenWikiRender.saveScreenshot(printerDir, dirname, "slice_" + yIndex + ".png", 0, 0, mc.displayWidth, mc.displayHeight, 0xFFFF00FF);
|
||||
|
||||
yIndex++;
|
||||
}
|
||||
|
||||
private void setupRotation() {
|
||||
double scale = -24;
|
||||
|
||||
GL11.glTranslated(width / 2, height / 2 - 36, 400);
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
GL11.glScaled(1, 1, 0.5); //incredible flattening power
|
||||
|
||||
GL11.glRotated(-30, 1, 0, 0);
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
|
||||
if(dir == ForgeDirection.WEST) {
|
||||
GL11.glRotated(180, 0, 1, 0);
|
||||
} else if(dir == ForgeDirection.NORTH) {
|
||||
GL11.glRotated(-90, 0, 1, 0);
|
||||
} else if(dir == ForgeDirection.SOUTH) {
|
||||
GL11.glRotated(90, 0, 1, 0);
|
||||
}
|
||||
|
||||
if(dir == ForgeDirection.WEST || dir == ForgeDirection.EAST) {
|
||||
GL11.glTranslated(sizeX / -2D, -sizeY / 2D, sizeZ / -2D);
|
||||
} else {
|
||||
GL11.glTranslated(sizeZ / -2D, -sizeY / 2D, sizeX / -2D);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,19 +19,18 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIScreenWikiRender extends GuiScreen {
|
||||
|
||||
// Basically the same thing as GUIScreenPreview, but will iterate through all provided preview stacks
|
||||
// taking a screenshot of each, as fast as the game can render them
|
||||
// Basically the same thing as GUIScreenPreview, but will iterate through all provided preview stacks
|
||||
// taking a screenshot of each, as fast as the game can render them
|
||||
|
||||
protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/nei/gui_nei.png");
|
||||
protected ItemStack[] preview;
|
||||
protected int index = 0;
|
||||
protected int index = 0;
|
||||
protected int scale = 1;
|
||||
protected String saveLocation = "wiki-screenshots";
|
||||
protected String prefix = "";
|
||||
@ -52,65 +51,38 @@ public class GUIScreenWikiRender extends GuiScreen {
|
||||
this.getStackName = getStackName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
if(this.mc.theWorld != null) {
|
||||
GuiScreen.drawRect(0, 0, this.width, this.height, 0xFFC6C6C6);
|
||||
} else {
|
||||
this.drawBackground(0);
|
||||
GuiScreen.drawRect(0, 0, this.width, this.height, 0xFFFF00FF);
|
||||
|
||||
// Once we've reached the end of the array, immedaitely close this GUI
|
||||
if(index >= preview.length) {
|
||||
this.mc.thePlayer.closeScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
// Once we've reached the end of the array, immedaitely close this GUI
|
||||
if(index >= preview.length) {
|
||||
this.mc.thePlayer.closeScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
this.drawGuiContainerBackgroundLayer();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
this.drawGuiContainerForegroundLayer(preview[index]);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
|
||||
ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
|
||||
int zoom = scale * res.getScaleFactor();
|
||||
|
||||
try {
|
||||
String slotName = getStackName.apply(preview[index]).replaceAll("§.", "").replaceAll("[^\\w ().-]+", "");
|
||||
if(!slotName.endsWith(".name")) {
|
||||
saveScreenshot(Minecraft.getMinecraft().mcDataDir, saveLocation, prefix + slotName + ".png", zoom, zoom, zoom * 16, zoom * 16, 0xFF8B8B8B);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Just skip any failures caused by display name or rendering
|
||||
}
|
||||
try {
|
||||
String slotName = getStackName.apply(preview[index]).replaceAll("§.", "").replaceAll("[^\\w ().-]+", "");
|
||||
if(!slotName.endsWith(".name")) {
|
||||
saveScreenshot(Minecraft.getMinecraft().mcDataDir, saveLocation, prefix + slotName + ".png", zoom, zoom, zoom * 16, zoom * 16, 0xFFFF00FF);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Just skip any failures caused by display name or rendering
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer() {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
this.drawTexturedModalRect(0, res.getScaledHeight_double() / scale - 18D, 5, 87, 18, 18);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void drawTexturedModalRect(double x, double y, int sourceX, int sourceY, int sizeX, int sizeY) {
|
||||
double f = 0.00390625D;
|
||||
double f1 = 0.00390625D;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double) (x + 0), (double) (y + sizeY), (double) this.zLevel, (double) ((float) (sourceX + 0) * f), (double) ((float) (sourceY + sizeY) * f1));
|
||||
tessellator.addVertexWithUV((double) (x + sizeX), (double) (y + sizeY), (double) this.zLevel, (double) ((float) (sourceX + sizeX) * f), (double) ((float) (sourceY + sizeY) * f1));
|
||||
tessellator.addVertexWithUV((double) (x + sizeX), (double) (y + 0), (double) this.zLevel, (double) ((float) (sourceX + sizeX) * f), (double) ((float) (sourceY + 0) * f1));
|
||||
tessellator.addVertexWithUV((double) (x + 0), (double) (y + 0), (double) this.zLevel, (double) ((float) (sourceX + 0) * f), (double) ((float) (sourceY + 0) * f1));
|
||||
tessellator.draw();
|
||||
index++;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(ItemStack preview) {
|
||||
if(preview == null) return;
|
||||
|
||||
|
||||
GL11.glPushMatrix();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||
@ -119,11 +91,11 @@ public class GUIScreenWikiRender extends GuiScreen {
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
|
||||
|
||||
ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
|
||||
GL11.glTranslated(9D, res.getScaledHeight_double() / scale - 9D, -200);
|
||||
GL11.glTranslated(9D, res.getScaledHeight_double() / scale - 9D, -200);
|
||||
|
||||
this.zLevel = 200.0F;
|
||||
itemRender.zLevel = 200.0F;
|
||||
@ -134,7 +106,7 @@ public class GUIScreenWikiRender extends GuiScreen {
|
||||
|
||||
itemRender.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@ -144,7 +116,7 @@ public class GUIScreenWikiRender extends GuiScreen {
|
||||
|
||||
// This implementation is based directly on ScreenShotHelper.saveScreenshot()
|
||||
// But allows for defining a rect where you want to sample pixels from
|
||||
private static void saveScreenshot(File dataDir, String ssDir, String fileName, int x, int y, int width, int height, int transparentColor) {
|
||||
public static void saveScreenshot(File dataDir, String ssDir, String fileName, int x, int y, int width, int height, int transparentColor) {
|
||||
try {
|
||||
File screenshotDirectory = new File(dataDir, ssDir);
|
||||
screenshotDirectory.mkdir();
|
||||
|
||||
@ -64,7 +64,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ModItems {
|
||||
|
||||
|
||||
public static HashSet<Item> excludeNEI = new HashSet();
|
||||
|
||||
public static void mainRegistry() {
|
||||
@ -645,7 +645,7 @@ public class ModItems {
|
||||
public static Item seg_10;
|
||||
public static Item seg_15;
|
||||
public static Item seg_20;
|
||||
|
||||
|
||||
public static Item combine_scrap;
|
||||
|
||||
public static Item shimmer_head;
|
||||
@ -1035,6 +1035,7 @@ public class ModItems {
|
||||
public static Item pwr_fuel;
|
||||
public static Item pwr_fuel_hot;
|
||||
public static Item pwr_fuel_depleted;
|
||||
public static Item pwr_printer;
|
||||
|
||||
public static Item rbmk_lid;
|
||||
public static Item rbmk_lid_glass;
|
||||
@ -1477,7 +1478,6 @@ public class ModItems {
|
||||
public static Item gun_double_barrel;
|
||||
public static Item gun_double_barrel_sacred_dragon;
|
||||
public static Item gun_n_i_4_n_i;
|
||||
|
||||
public static Item gun_charge_thrower;
|
||||
|
||||
public static Item ammo_standard;
|
||||
@ -2073,7 +2073,7 @@ public class ModItems {
|
||||
public static Item hazmat_paa_boots;
|
||||
|
||||
public static Item rebar_placer;
|
||||
|
||||
|
||||
public static Item wand;
|
||||
public static Item wand_s;
|
||||
public static Item wand_d;
|
||||
@ -2235,7 +2235,7 @@ public class ModItems {
|
||||
public static Item conveyor_wand;
|
||||
|
||||
public static void initializeItem() {
|
||||
|
||||
|
||||
redstone_sword = new RedstoneSword(ToolMaterial.STONE).setUnlocalizedName("redstone_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":redstone_sword");
|
||||
big_sword = new BigSword(ToolMaterial.EMERALD).setUnlocalizedName("big_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":big_sword");
|
||||
|
||||
@ -2967,7 +2967,7 @@ public class ModItems {
|
||||
gas_full = new ItemGasTank().setUnlocalizedName("gas_full").setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.gas_empty).setTextureName(RefStrings.MODID + ":gas_empty");
|
||||
|
||||
ItemSimpleConsumable.init();
|
||||
|
||||
|
||||
//TODO: move all this crap to ItemSimpleConsumable
|
||||
syringe_empty = new Item().setUnlocalizedName("syringe_empty").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_empty");
|
||||
syringe_metal_empty = new Item().setUnlocalizedName("syringe_metal_empty").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_empty");
|
||||
@ -2977,7 +2977,7 @@ public class ModItems {
|
||||
syringe_metal_super = new ItemSyringe().setUnlocalizedName("syringe_metal_super").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_super");
|
||||
syringe_taint = new ItemSyringe().setUnlocalizedName("syringe_taint").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_taint");
|
||||
syringe_mkunicorn = new ItemSyringe().setUnlocalizedName("syringe_mkunicorn").setFull3D().setCreativeTab(null).setTextureName(RefStrings.MODID + ":syringe_mkunicorn");
|
||||
|
||||
|
||||
med_bag = new ItemSyringe().setUnlocalizedName("med_bag").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":med_bag");
|
||||
radx = new ItemPill(0).setUnlocalizedName("radx").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radx");
|
||||
siox = new ItemPill(0).setUnlocalizedName("siox").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":siox");
|
||||
@ -3182,6 +3182,7 @@ public class ModItems {
|
||||
pwr_fuel = new ItemPWRFuel().setUnlocalizedName("pwr_fuel").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel");
|
||||
pwr_fuel_hot = new ItemEnumMulti(EnumPWRFuel.class, true, false).setUnlocalizedName("pwr_fuel_hot").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel_hot");
|
||||
pwr_fuel_depleted = new ItemEnumMulti(EnumPWRFuel.class, true, false).setUnlocalizedName("pwr_fuel_depleted").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel_depleted");
|
||||
pwr_printer = new ItemPWRPrinter().setUnlocalizedName("pwr_printer").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_printer");
|
||||
|
||||
rbmk_lid = new ItemRBMKLid().setUnlocalizedName("rbmk_lid").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid");
|
||||
rbmk_lid_glass = new ItemRBMKLid().setUnlocalizedName("rbmk_lid_glass").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid_glass");
|
||||
@ -4513,7 +4514,7 @@ public class ModItems {
|
||||
.addAbility(IToolHarvestAbility.SMELTER, 0)
|
||||
.addAbility(IToolHarvestAbility.SILK, 0)
|
||||
.addAbility(IToolHarvestAbility.LUCK, 2).setUnlocalizedName("cmb_pickaxe").setTextureName(RefStrings.MODID + ":cmb_pickaxe");
|
||||
|
||||
|
||||
cmb_axe = new ItemToolAbility(30F, 0, MainRegistry.tMatCMB, EnumToolType.AXE)
|
||||
.addAbility(IToolAreaAbility.RECURSION, 2)
|
||||
.addAbility(IToolHarvestAbility.SMELTER, 0)
|
||||
@ -4538,7 +4539,7 @@ public class ModItems {
|
||||
.addAbility(IToolAreaAbility.RECURSION, 2)
|
||||
.addAbility(IToolHarvestAbility.SILK, 0)
|
||||
.addAbility(IToolHarvestAbility.LUCK, 1).setUnlocalizedName("elec_pickaxe").setTextureName(RefStrings.MODID + ":elec_drill_anim");
|
||||
|
||||
|
||||
elec_axe = new ItemToolAbilityPower(10F, 0, MainRegistry.tMatElec, EnumToolType.AXE, 500000, 1000, 100)
|
||||
.addAbility(IToolAreaAbility.HAMMER, 1)
|
||||
.addAbility(IToolAreaAbility.HAMMER_FLAT, 1)
|
||||
@ -4547,14 +4548,14 @@ public class ModItems {
|
||||
.addAbility(IToolHarvestAbility.LUCK, 1)
|
||||
.addAbility(IWeaponAbility.CHAINSAW, 0)
|
||||
.addAbility(IWeaponAbility.BEHEADER, 0).setShears().setUnlocalizedName("elec_axe").setTextureName(RefStrings.MODID + ":elec_chainsaw_anim");
|
||||
|
||||
|
||||
elec_shovel = new ItemToolAbilityPower(5F, 0, MainRegistry.tMatElec, EnumToolType.SHOVEL, 500000, 1000, 100)
|
||||
.addAbility(IToolAreaAbility.HAMMER, 1)
|
||||
.addAbility(IToolAreaAbility.HAMMER_FLAT, 1)
|
||||
.addAbility(IToolAreaAbility.RECURSION, 2)
|
||||
.addAbility(IToolHarvestAbility.SILK, 0)
|
||||
.addAbility(IToolHarvestAbility.LUCK, 1).setUnlocalizedName("elec_shovel").setTextureName(RefStrings.MODID + ":elec_shovel_anim");
|
||||
|
||||
|
||||
desh_sword = new ItemSwordAbility(12.5F, 0, MainRegistry.tMatDesh)
|
||||
.addAbility(IWeaponAbility.STUN, 0).setUnlocalizedName("desh_sword").setTextureName(RefStrings.MODID + ":desh_sword");
|
||||
|
||||
@ -4564,7 +4565,7 @@ public class ModItems {
|
||||
.addAbility(IToolAreaAbility.RECURSION, 0)
|
||||
.addAbility(IToolHarvestAbility.SILK, 0)
|
||||
.addAbility(IToolHarvestAbility.LUCK, 1).setUnlocalizedName("desh_pickaxe").setTextureName(RefStrings.MODID + ":desh_pickaxe");
|
||||
|
||||
|
||||
desh_axe = new ItemToolAbility(7.5F, -0.05, MainRegistry.tMatDesh, EnumToolType.AXE)
|
||||
.addAbility(IToolAreaAbility.HAMMER, 0)
|
||||
.addAbility(IToolAreaAbility.HAMMER_FLAT, 0)
|
||||
@ -4979,9 +4980,9 @@ public class ModItems {
|
||||
}
|
||||
|
||||
private static void registerItem() {
|
||||
|
||||
|
||||
excludeNEI.add(item_secret);
|
||||
|
||||
|
||||
//Weapons
|
||||
GameRegistry.registerItem(redstone_sword, redstone_sword.getUnlocalizedName());
|
||||
GameRegistry.registerItem(big_sword, big_sword.getUnlocalizedName());
|
||||
@ -5688,7 +5689,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(fluid_barrel_empty, fluid_barrel_empty.getUnlocalizedName());
|
||||
GameRegistry.registerItem(fluid_barrel_full, fluid_barrel_full.getUnlocalizedName());
|
||||
GameRegistry.registerItem(fluid_barrel_infinite, fluid_barrel_infinite.getUnlocalizedName());
|
||||
|
||||
|
||||
//Packaged fluids
|
||||
GameRegistry.registerItem(fluid_pack_empty, fluid_pack_empty.getUnlocalizedName());
|
||||
GameRegistry.registerItem(fluid_pack_full, fluid_pack_full.getUnlocalizedName());
|
||||
@ -5995,6 +5996,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(pwr_fuel, pwr_fuel.getUnlocalizedName());
|
||||
GameRegistry.registerItem(pwr_fuel_hot, pwr_fuel_hot.getUnlocalizedName());
|
||||
GameRegistry.registerItem(pwr_fuel_depleted, pwr_fuel_depleted.getUnlocalizedName());
|
||||
GameRegistry.registerItem(pwr_printer, pwr_printer.getUnlocalizedName());
|
||||
|
||||
//RBMK parts
|
||||
GameRegistry.registerItem(rbmk_lid, rbmk_lid.getUnlocalizedName());
|
||||
|
||||
176
src/main/java/com/hbm/items/machine/ItemPWRPrinter.java
Normal file
176
src/main/java/com/hbm/items/machine/ItemPWRPrinter.java
Normal file
@ -0,0 +1,176 @@
|
||||
package com.hbm.items.machine;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.BlockPWR;
|
||||
import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR;
|
||||
import com.hbm.inventory.gui.GUIScreenSlicePrinter;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.machine.TileEntityPWRController;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ItemPWRPrinter extends Item implements IGUIProvider {
|
||||
|
||||
private static int x1, y1, z1;
|
||||
private static int x2, y2, z2;
|
||||
private static Block[] blockSync;
|
||||
private static ForgeDirection dir;
|
||||
|
||||
private HashSet<BlockPos> fill = new HashSet<>();
|
||||
private static HashSet<Block> whitelist = new HashSet<Block>() {{
|
||||
add(ModBlocks.pwr_block);
|
||||
add(ModBlocks.pwr_controller);
|
||||
}};
|
||||
|
||||
// Piggybacking functions using the bytebuf TE sync
|
||||
public static void serialize(World world, ByteBuf buf) {
|
||||
buf.writeInt(x1);
|
||||
buf.writeInt(y1);
|
||||
buf.writeInt(z1);
|
||||
buf.writeInt(x2);
|
||||
buf.writeInt(y2);
|
||||
buf.writeInt(z2);
|
||||
buf.writeInt(dir.ordinal());
|
||||
|
||||
for(Block block : blockSync) {
|
||||
buf.writeInt(Block.getIdFromBlock(block));
|
||||
}
|
||||
|
||||
blockSync = null;
|
||||
}
|
||||
|
||||
public static void deserialize(World world, ByteBuf buf) {
|
||||
x1 = buf.readInt();
|
||||
y1 = buf.readInt();
|
||||
z1 = buf.readInt();
|
||||
x2 = buf.readInt();
|
||||
y2 = buf.readInt();
|
||||
z2 = buf.readInt();
|
||||
dir = ForgeDirection.values()[buf.readInt()];
|
||||
|
||||
for(int x = x1; x <= x2; x++) {
|
||||
for(int y = y1; y <= y2; y++) {
|
||||
for(int z = z1; z <= z2; z++) {
|
||||
Block block = Block.getBlockById(buf.readInt());
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(!(tile instanceof TileEntityBlockPWR)) continue;
|
||||
((TileEntityBlockPWR) tile).block = block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("oh wow it synced and attempted to GUI!");
|
||||
|
||||
// Open the printer GUI on any client players holding the printer
|
||||
// yeah it's a shit hack yay weee wooo
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if(player != null && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemPWRPrinter) {
|
||||
FMLNetworkHandler.openGui(Minecraft.getMinecraft().thePlayer, MainRegistry.instance, 0, world, 0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f0, float f1, float f2) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(!(tile instanceof TileEntityPWRController)) return false;
|
||||
if(world.isRemote) return true;
|
||||
|
||||
TileEntityPWRController pwr = (TileEntityPWRController) tile;
|
||||
syncAndScreenshot(world, pwr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void syncAndScreenshot(World world, TileEntityPWRController pwr) {
|
||||
findBounds(world, pwr);
|
||||
|
||||
int sizeX = x2 - x1 + 1;
|
||||
int sizeY = y2 - y1 + 1;
|
||||
int sizeZ = z2 - z1 + 1;
|
||||
|
||||
blockSync = new Block[sizeX * sizeY * sizeZ];
|
||||
int i = 0;
|
||||
|
||||
for(int x = x1; x <= x2; x++) {
|
||||
for(int y = y1; y <= y2; y++) {
|
||||
for(int z = z1; z <= z2; z++) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBlockPWR) {
|
||||
blockSync[i] = ((TileEntityBlockPWR) tile).block;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pwr.isPrinting = true;
|
||||
}
|
||||
|
||||
public void findBounds(World world, TileEntityPWRController pwr) {
|
||||
dir = ForgeDirection.getOrientation(world.getBlockMetadata(pwr.xCoord, pwr.yCoord, pwr.zCoord)).getOpposite();
|
||||
|
||||
fill.clear();
|
||||
fill.add(new BlockPos(pwr.xCoord, pwr.yCoord, pwr.zCoord));
|
||||
x1 = x2 = pwr.xCoord;
|
||||
y1 = y2 = pwr.yCoord;
|
||||
z1 = z2 = pwr.zCoord;
|
||||
floodFill(world, pwr.xCoord + dir.offsetX, pwr.yCoord, pwr.zCoord + dir.offsetZ);
|
||||
}
|
||||
|
||||
public void floodFill(World world, int x, int y, int z) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
if(fill.contains(pos)) return;
|
||||
|
||||
if(world.getBlock(x, y, z) instanceof BlockPWR) {
|
||||
fill.add(pos);
|
||||
|
||||
x1 = Math.min(x1, x);
|
||||
y1 = Math.min(y1, y);
|
||||
z1 = Math.min(z1, z);
|
||||
x2 = Math.max(x2, x);
|
||||
y2 = Math.max(y2, y);
|
||||
z2 = Math.max(z2, z);
|
||||
|
||||
floodFill(world, x + 1, y, z);
|
||||
floodFill(world, x - 1, y, z);
|
||||
floodFill(world, x, y + 1, z);
|
||||
floodFill(world, x, y - 1, z);
|
||||
floodFill(world, x, y, z + 1);
|
||||
floodFill(world, x, y, z - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIScreenSlicePrinter(x1, y1, z1, x2, y2, z2, dir, whitelist);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
|
||||
list.add("Use on a constructed PWR controller to generate construction diagrams");
|
||||
}
|
||||
|
||||
}
|
||||
@ -12,12 +12,13 @@ import com.hbm.inventory.container.ContainerPWR;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable;
|
||||
import com.hbm.inventory.fluid.trait.FT_PWRModerator;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingStep;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType;
|
||||
import com.hbm.inventory.fluid.trait.FT_PWRModerator;
|
||||
import com.hbm.inventory.gui.GUIPWR;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel;
|
||||
import com.hbm.items.machine.ItemPWRPrinter;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.sound.AudioWrapper;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
@ -375,8 +376,17 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
||||
return this.rodCount + (int) Math.ceil(this.heatsinkCount / 4D);
|
||||
}
|
||||
|
||||
public boolean isPrinting;
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
buf.writeBoolean(isPrinting);
|
||||
if(isPrinting) {
|
||||
ItemPWRPrinter.serialize(worldObj, buf);
|
||||
isPrinting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
super.serialize(buf);
|
||||
buf.writeInt(this.rodCount);
|
||||
buf.writeLong(this.coreHeat);
|
||||
@ -395,6 +405,14 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
if(buf.readBoolean()) {
|
||||
// piggybacking off of this packet so that we don't have to sync EVERY PWR
|
||||
// block continuously to the client for one tiny screenshot tool
|
||||
|
||||
ItemPWRPrinter.deserialize(worldObj, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
super.deserialize(buf);
|
||||
this.rodCount = buf.readInt();
|
||||
this.coreHeat = buf.readLong();
|
||||
|
||||
@ -4109,6 +4109,7 @@ item.pwr_fuel_hot.men.name=Hot MEN PWR Fuel Rod
|
||||
item.pwr_fuel_hot.mep.name=Hot MEP PWR Fuel Rod
|
||||
item.pwr_fuel_hot.meu.name=Hot MEU PWR Fuel Rod
|
||||
item.pwr_fuel_hot.mox.name=Hot MOX PWR Fuel Rod
|
||||
item.pwr_printer.name=PWR Printer
|
||||
item.quartz_plutonium.name=Plutonic Quartz
|
||||
item.radar_linker.name=Radar Linker
|
||||
item.radaway.name=RadAway
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/items/pwr_printer.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/pwr_printer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 433 B |
Loading…
x
Reference in New Issue
Block a user