multiblock construction NEI handler (wow!), better bolting

This commit is contained in:
Boblet 2023-04-21 14:39:33 +02:00
parent ed829fc7ec
commit 8ec678564f
17 changed files with 284 additions and 32 deletions

View File

@ -1,9 +1,12 @@
package com.hbm.blocks;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
public class BlockEnumMulti extends BlockMulti {
@ -38,6 +41,16 @@ public class BlockEnumMulti extends BlockMulti {
}
}
public String getUnlocalizedName(ItemStack stack) {
if(this.multiName) {
Enum num = EnumUtil.grabEnumSafely(this.theEnum, stack.getItemDamage());
return super.getUnlocalizedName() + "." + num.name().toLowerCase();
}
return this.getUnlocalizedName();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {

View File

@ -31,4 +31,8 @@ public abstract class BlockMulti extends BlockBase implements IBlockMulti {
list.add(new ItemStack(item, 1, i));
}
}
public String getUnlocalizedName(ItemStack stack) {
return this.getUnlocalizedName();
}
}

View File

@ -23,7 +23,6 @@ import com.hbm.main.MainRegistry;
import com.hbm.tileentity.DoorDecl;
import com.hbm.tileentity.machine.storage.TileEntityFileCabinet;
import api.hbm.block.IToolable.ToolType;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
@ -1981,7 +1980,7 @@ public class ModBlocks {
watz_element = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_element_top").setBlockName("watz_element").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_element_side");
watz_control = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_control_top").setBlockName("watz_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_control_side");
watz_cooler = new BlockGeneric(Material.iron).setBlockName("watz_cooler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_cooler");
watz_cooler = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_cooler_top").setBlockName("watz_cooler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_cooler_side");
watz_end = new BlockToolConversion(Material.iron).addVariant("_bolted").setBlockName("watz_end").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_casing");
watz_hatch = new WatzHatch(Material.iron).setBlockName("watz_hatch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_hatch");
watz_conductor = new BlockCableConnect(Material.iron).setBlockName("watz_conductor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_conductor_top");

View File

@ -5,8 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import com.hbm.blocks.BlockBase;
import com.hbm.blocks.IBlockMulti;
import com.hbm.blocks.BlockMulti;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.RecipesCommon.AStack;
@ -23,16 +22,14 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
public class BlockToolConversion extends BlockBase implements IToolable, ILookOverlay, IBlockMulti {
public class BlockToolConversion extends BlockMulti implements IToolable, ILookOverlay {
public IIcon[] icons;
public String[] names;
@ -46,14 +43,6 @@ public class BlockToolConversion extends BlockBase implements IToolable, ILookOv
return this;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < getSubCount(); ++i) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
@ -67,6 +56,18 @@ public class BlockToolConversion extends BlockBase implements IToolable, ILookOv
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
int meta = stack.getItemDamage() - 1;
if(meta == -1 || names == null || meta >= names.length) {
return this.getUnlocalizedName();
}
return this.getUnlocalizedName() + names[meta];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {

View File

@ -1,12 +1,17 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.items.ModItems;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityWatz;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -71,4 +76,21 @@ public class Watz extends BlockDummyable {
this.makeExtra(world, x, y + 2, z - 2);
this.makeExtra(world, x, y + 2, z);
}
public static boolean drop = true;
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int i) {
if(i >= 12 && drop) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.watz_end, 48)));
for(int j = 0; j < 3; j++) world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.bolt_dura_steel, 64)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.watz_element, 36)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.watz_cooler, 26)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.struct_watz_core, 1)));
}
super.breakBlock(world, x, y, z, block, i);
}
}

View File

@ -0,0 +1,59 @@
package com.hbm.handler.nei;
import java.util.HashMap;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import net.minecraft.item.ItemStack;
public class ConstructionHandler extends NEIUniversalHandler {
public ConstructionHandler() {
super("Construction", getRecipes(true), getRecipes(false));
}
@Override
public String getKey() {
return "ntmConstruction";
}
public static HashMap<Object[], Object> bufferedRecipes = new HashMap();
public static HashMap<Object[], Object> bufferedTools = new HashMap();
public static HashMap<Object[], Object> getRecipes(boolean recipes) {
if(!bufferedRecipes.isEmpty()) {
return recipes ? bufferedRecipes : bufferedTools;
}
/* WATZ */
ItemStack[] watz = new ItemStack[] {
new ItemStack(ModBlocks.watz_end, 48),
new ItemStack(ModItems.bolt_dura_steel, 64),
new ItemStack(ModItems.bolt_dura_steel, 64),
new ItemStack(ModItems.bolt_dura_steel, 64),
new ItemStack(ModBlocks.watz_element, 36),
new ItemStack(ModBlocks.watz_cooler, 26),
new ItemStack(ModItems.boltgun)};
bufferedRecipes.put(watz, new ItemStack(ModBlocks.watz));
bufferedTools.put(watz, new ItemStack(ModBlocks.struct_watz_core));
/* ITER */
ItemStack[] iter = new ItemStack[] {
new ItemStack(ModBlocks.fusion_conductor, 64),
new ItemStack(ModBlocks.fusion_conductor, 64),
new ItemStack(ModBlocks.fusion_conductor, 64),
new ItemStack(ModBlocks.fusion_conductor, 64),
new ItemStack(ModBlocks.fusion_conductor, 36),
new ItemStack(ModBlocks.fusion_center, 64),
new ItemStack(ModBlocks.fusion_motor, 4),
new ItemStack(ModBlocks.reinforced_glass, 8)};
bufferedRecipes.put(iter, new ItemStack(ModBlocks.iter));
bufferedTools.put(iter, new ItemStack(ModBlocks.struct_iter_core));
return recipes ? bufferedRecipes : bufferedTools;
}
}

View File

@ -60,16 +60,16 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
public RecipeSet(ItemStack[][] in, ItemStack[][] out, Object originalInputInstance /* for custom machine lookup */) {
input = new PositionedStack[in.length];
int[][] inPos = NEIUniversalHandler.getInputCoords(in.length);
for(int i = 0; i < in.length; i++) {
ItemStack[] sub = in[i];
this.input[i] = new PositionedStack(sub, 48 + i * -18, 24);
this.input[i] = new PositionedStack(sub, inPos[i][0], inPos[i][1]);
}
output = new PositionedStack[out.length];
int[][] outPos = NEIUniversalHandler.getOutputCoords(out.length);
for(int i = 0; i < out.length; i++) {
ItemStack[] sub = out[i];
boolean twos = out.length > 3;
this.output[i] = new PositionedStack(sub, 102 + i * 18 - ((twos && i > 1) ? 36 : 0), 24 + (twos ? (i < 2 ? -9 : 9) : 0));
this.output[i] = new PositionedStack(sub, outPos[i][0], outPos[i][1]);
}
ItemStack[] m = machine;
@ -122,16 +122,115 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler {
RecipeSet rec = (RecipeSet) this.arecipes.get(recipe);
for(int i = 0; i < rec.input.length; i++)
drawTexturedModalRect(47 + i * -18, 23, 5, 87, 18, 18);
for(int i = 0; i < rec.output.length; i++) {
boolean twos = rec.output.length > 3;
drawTexturedModalRect(101 + i * 18 - ((twos && i > 1) ? 36 : 0), 23 + (twos ? (i < 2 ? -9 : 9) : 0), 5, 87, 18, 18);
int[][] inPos = NEIUniversalHandler.getInputCoords(rec.input.length);
for(int[] pos : inPos) {
drawTexturedModalRect(pos[0] - 1, pos[1] - 1, 5, 87, 18, 18);
}
int[][] outPos = NEIUniversalHandler.getOutputCoords(rec.output.length);
for(int[] pos : outPos) {
drawTexturedModalRect(pos[0] - 1, pos[1] - 1, 5, 87, 18, 18);
}
drawTexturedModalRect(74, 14, 59, 87, 18, 38);
}
public static int[][] getInputCoords(int count) {
switch(count) {
case 1: return new int[][] {
{48, 24}
};
case 2: return new int[][] {
{48, 24},
{30, 24}
};
case 3: return new int[][] {
{48, 24},
{30, 24},
{12, 24}
};
case 4: return new int[][] {
{48, 24 - 9},
{30, 24 - 9},
{48, 24 + 9},
{30, 24 + 9}
};
case 5: return new int[][] {
{48, 24 - 9},
{30, 24 - 9},
{12, 24},
{48, 24 + 9},
{30, 24 + 9},
};
case 6: return new int[][] {
{48, 24 - 9},
{30, 24 - 9},
{12, 24 - 9},
{48, 24 + 9},
{30, 24 + 9},
{12, 24 + 9}
};
case 7: return new int[][] {
{48, 24 - 18},
{30, 24 - 9},
{12, 24 - 9},
{48, 24},
{30, 24 + 9},
{12, 24 + 9},
{48, 24 + 18}
};
case 8: return new int[][] {
{48, 24 - 18},
{30, 24 - 18},
{12, 24 - 9},
{48, 24},
{30, 24},
{12, 24 + 9},
{48, 24 + 18},
{30, 24 + 18}
};
case 9: return new int[][] {
{48, 24 - 18},
{30, 24 - 18},
{12, 24 - 18},
{48, 24},
{30, 24},
{12, 24},
{48, 24 + 18},
{30, 24 + 18},
{12, 24 + 18}
};
}
return new int[count][2];
}
public static int[][] getOutputCoords(int count) {
switch(count) {
case 1: return new int[][] {
{102, 24}
};
case 2: return new int[][] {
{102, 24},
{120, 24}
};
case 3: return new int[][] {
{102, 24},
{120, 24},
{138, 24}
};
case 4: return new int[][] {
{102, 24 - 9},
{120, 24 - 9},
{138 + 36, 24 + 9},
{156 + 36, 24 + 9}
};
}
return new int[count][2];
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {

View File

@ -2,12 +2,11 @@ package com.hbm.items.block;
import java.util.List;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.blocks.BlockMulti;
import com.hbm.blocks.IBlockMulti;
import com.hbm.blocks.IPersistentInfoProvider;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.tileentity.IPersistentNBT;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -41,10 +40,8 @@ public class ItemBlockBase extends ItemBlock {
@Override
public String getUnlocalizedName(ItemStack stack) {
if(field_150939_a instanceof BlockEnumMulti && ((BlockEnumMulti)field_150939_a).multiName) {
Enum num = EnumUtil.grabEnumSafely(((BlockEnumMulti)field_150939_a).theEnum, stack.getItemDamage());
return super.getUnlocalizedName() + "." + num.name().toLowerCase();
if(field_150939_a instanceof BlockMulti) {
return ((BlockMulti)field_150939_a).getUnlocalizedName(stack);
} else {
return super.getUnlocalizedName(stack);
}

View File

@ -1,7 +1,10 @@
package com.hbm.items.tool;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.IAnimatedItem;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.render.anim.BusAnimation;
@ -14,11 +17,13 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -26,6 +31,7 @@ public class ItemBoltgun extends Item implements IAnimatedItem {
public ItemBoltgun() {
this.setMaxStackSize(1);
this.setCreativeTab(MainRegistry.controlTab);
ToolType.BOLT.register(new ItemStack(this));
}
@ -37,6 +43,47 @@ public class ItemBoltgun extends Item implements IAnimatedItem {
return this;
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
World world = player.worldObj;
if(!entity.isEntityAlive()) return false;
Item[] bolts = new Item[] { ModItems.bolt_dura_steel, ModItems.bolt_tungsten, Item.getItemFromBlock(ModBlocks.steel_beam) };
for(Item item : bolts) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack slot = player.inventory.getStackInSlot(i);
if(slot != null) {
if(slot.getItem() == item) {
if(!world.isRemote) {
player.inventory.decrStackSize(i, 1);
player.inventoryContainer.detectAndSendChanges();
entity.attackEntityFrom(DamageSource.causePlayerDamage(player).setDamageBypassesArmor(), 10F);
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt");
data.setString("mode", "largeexplode");
data.setFloat("size", 1F);
data.setByte("count", (byte)1);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, entity.posX, entity.posY + entity.height / 2 - entity.yOffset, entity.posZ), new TargetPoint(world.provider.dimensionId, entity.posX, entity.posY, entity.posZ, 50));
} else {
// doing this on the client outright removes the packet delay and makes the animation silky-smooth
NBTTagCompound d0 = new NBTTagCompound();
d0.setString("type", "anim");
d0.setString("mode", "generic");
MainRegistry.proxy.effectNT(d0);
}
return true;
}
}
}
}
return false;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float fX, float fY, float fZ) {

View File

@ -54,6 +54,7 @@ public class NEIConfig implements IConfigureNEI {
registerHandler(new CrucibleAlloyingHandler());
registerHandler(new CrucibleCastingHandler());
registerHandler(new ToolingHandler());
registerHandler(new ConstructionHandler());
//universal boyes
registerHandler(new ZirnoxRecipeHandler());

View File

@ -6,6 +6,7 @@ import com.hbm.main.ResourceManager;
import com.hbm.render.anim.HbmAnimations;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
@ -33,6 +34,8 @@ public class ItemRenderBoltgun implements IItemRenderer {
GL11.glPushMatrix();
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_SMOOTH);
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.boltgun_tex);
@ -50,6 +53,7 @@ public class ItemRenderBoltgun implements IItemRenderer {
GL11.glPushMatrix();
double[] anim = HbmAnimations.getRelevantTransformation("RECOIL");
GL11.glTranslated(0, 0, -anim[0]);
if(anim[0] != 0) player.isSwingInProgress = false;
ResourceManager.boltgun.renderPart("Barrel");
GL11.glPopMatrix();

View File

@ -62,7 +62,7 @@ public class TileEntityWatzStruct extends TileEntity {
Watz watz = (Watz)ModBlocks.watz;
BlockDummyable.safeRem = true;
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.watz, this.getBlockMetadata() + BlockDummyable.offset, 3);
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.watz, 12, 3);
watz.fillSpace(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, 0);
BlockDummyable.safeRem = false;
}

View File

@ -1205,6 +1205,7 @@ item.bobmazon_weapons.name=Bobmazon: Waffen und Sprengstoffe
item.bolt_compound.name=Verstärkte Turbinenwelle
item.bolt_dura_steel.name=Schnellarbeitsstahlbolzen
item.bolt_tungsten.name=Wolframbolzen
item.boltgun.name=Pneumatische Nietenpistole
item.bomb_caller.name=Luftschlag Zielmarker
item.bomb_waffle.name=Massenvernichtungswaffel
item.guide_book.name=Handbuch
@ -4222,6 +4223,7 @@ tile.struct_launcher_core_large.name=Startrampe-Kernkomponente
tile.struct_plasma_core.name=Plasmaerhitzer-Kernkomponente
tile.struct_scaffold.name=Startrampe-Gerüstblock
tile.struct_soyuz_core.name=Soyuz-Startrampe-Kernkomponente
tile.struct_watz_core.name=Watzkraftwerk-Kernkomponente
tile.substation.name=Umspannwerk
tile.sulfuric_acid_block.name=Schwefelsäure
tile.taint.name=Korrupter Schmutz
@ -4281,6 +4283,7 @@ tile.watz_cooler.name=Watz-Superkühler
tile.watz_core.name=Watzreaktorkern
tile.watz_element.name=Watzreaktionskammer
tile.watz_end.name=Watz-Stabilitätselement
tile.watz_end_bolted.name=Watz-Stabilitätselement (Genietet)
tile.watz_hatch.name=Watzreaktorzugriffsluke
tile.yellow_barrel.name=Radioaktives Fass
tile.zirnox_destroyed.name=Zerstörter ZINOX

View File

@ -1792,6 +1792,7 @@ item.bobmazon_weapons.name=Bobmazon: Weapons and Explosives
item.bolt_compound.name=Reinforced Turbine Shaft
item.bolt_dura_steel.name=High-Speed Steel Bolt
item.bolt_tungsten.name=Tungsten Bolt
item.boltgun.name=Pneumatic Rivet Gun
item.bomb_caller.name=Airstrike Designator
item.bomb_waffle.name=Waffle of Mass Destruction
item.book_guide.name=Guide Book
@ -5038,6 +5039,7 @@ tile.struct_launcher_core_large.name=Launch Table Core Component
tile.struct_plasma_core.name=Plasma Heater Core Component
tile.struct_scaffold.name=Launch Pad Scaffold Block
tile.struct_soyuz_core.name=Soyuz Launcher Core Component
tile.struct_watz_core.name=Watz Powerplant Core Component
tile.substation.name=Substation
tile.sulfuric_acid_block.name=Sulfuric Acid
tile.taint.name=Taint
@ -5099,6 +5101,7 @@ tile.watz_cooler.name=Watz Reactor Supercooler
tile.watz_core.name=Watz Reactor Control
tile.watz_element.name=Watz Reaction Chamber
tile.watz_end.name=Watz Reactor Stability Element
tile.watz_end_bolted.name=Watz Reactor Stability Element (Riveted)
tile.watz_hatch.name=Watz Reactor Access Hatch
tile.yellow_barrel.name=Radioactive Barrel
tile.zirnox_destroyed.name=Destroyed ZINROX

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB