the malicious gigglefish from the silly dimension

This commit is contained in:
Bob 2023-07-18 18:34:16 +02:00
parent 05c87528a0
commit ecec7e5a36
41 changed files with 843 additions and 18 deletions

View File

@ -1,3 +1,11 @@
## Fixed
* Fixed bedrock ore to cobblestone being wrong, using actual ore blocks instead of the extracted item
* Fixed missing mapping on the template chest, causing crashes
## Added
* Rubber ball
* can be thrown at people
* New chlorine processing chain
* Involves 240 processing steps of washing, electrolyzing, centrifuging and treating chlorocalcite
## Changed
* Glyphids now have a higher tracking range, being 256 blocks
* Standard glyphids now have a base health of 100
* Glyphid scouts are now immune to fire and explosive damage, have a 50% damage reduction against projectiles and have passive regeneration
* Increased hive block blast resistance, they can no longer be blown up wiith conventional explosives

View File

@ -20,6 +20,19 @@ public class BlockEnums {
SULFUR,
ASBESTOS
}
public static enum EnumCMMaterials {
STEEL,
ALLOY,
DESH,
TCALLOY
}
public static enum EnumCMEngines {
STANDARD,
DESH,
BISMUTH
}
/** DECO / STRUCTURE ENUMS */
//i apologize in advance

View File

@ -864,6 +864,13 @@ public class ModBlocks {
@Deprecated public static Block factory_advanced_furnace;
@Deprecated public static Block factory_advanced_conductor;
public static Block cm_block;
public static Block cm_sheet;
public static Block cm_engine;
public static Block cm_tank;
public static Block cm_port;
public static Block custom_machine;
public static Block reactor_element;
public static Block reactor_control;
public static Block reactor_hatch;
@ -2013,6 +2020,13 @@ public class ModBlocks {
factory_advanced_furnace = new FactoryHatch(Material.iron).setBlockName("factory_advanced_furnace").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":factory_advanced_furnace");
factory_advanced_conductor = new BlockPillar(Material.iron, RefStrings.MODID + ":factory_advanced_conductor").setBlockName("factory_advanced_conductor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":factory_advanced_hull");
cm_block = new BlockCM(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_block").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_block");
cm_sheet = new BlockCM(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_sheet").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_sheet");
cm_engine = new BlockCM(Material.iron, EnumCMEngines.class, true, true).setBlockName("cm_engine").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_engine");
cm_tank = new BlockCMGlass(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_tank").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_tank");
cm_port = new BlockCM(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_port").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_port");
custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.blockTab).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");
reactor_hatch = new ReactorHatch(Material.iron).setBlockName("reactor_hatch").setHardness(5.0F).setResistance(1000.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_concrete");
@ -3331,6 +3345,14 @@ public class ModBlocks {
GameRegistry.registerBlock(factory_titanium_hull, factory_titanium_hull.getUnlocalizedName());
GameRegistry.registerBlock(factory_advanced_hull, factory_advanced_hull.getUnlocalizedName());
//CM stuff
register(custom_machine, ItemCustomMachine.class);
register(cm_block);
register(cm_sheet);
register(cm_engine);
register(cm_tank);
register(cm_port);
//Multiblock Generators
GameRegistry.registerBlock(reactor_element, reactor_element.getUnlocalizedName());
GameRegistry.registerBlock(reactor_control, reactor_control.getUnlocalizedName());

View File

@ -0,0 +1,30 @@
package com.hbm.blocks.machine;
import java.util.Locale;
import com.hbm.blocks.BlockEnumMulti;
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.util.IIcon;
public class BlockCM extends BlockEnumMulti {
public BlockCM(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
super(mat, theEnum, multiName, multiTexture);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
Enum[] enums = theEnum.getEnumConstants();
this.icons = new IIcon[enums.length];
for(int i = 0; i < icons.length; i++) {
Enum num = enums[i];
this.icons[i] = reg.registerIcon(this.getTextureName() + "_" + num.name().toLowerCase(Locale.US));
}
}
}

View File

@ -0,0 +1,31 @@
package com.hbm.blocks.machine;
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.world.IBlockAccess;
public class BlockCMGlass extends BlockCM {
public BlockCMGlass(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
super(mat, theEnum, multiName, multiTexture);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y, z);
return block == this ? false : super.shouldSideBeRendered(world, x, y, z, side);
}
}

View File

@ -0,0 +1,131 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityCustomMachine;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockCustomMachine extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
public BlockCustomMachine() {
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCustomMachine();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":cm_terminal_front");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":cm_terminal_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
}
@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) {
return true;
} else if(!player.isSneaking()) {
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
if(tile != null) {
if(tile.checkStructure()) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
} else if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.wand_s) {
tile.buildStructure();
}
}
return true;
}
return false;
}
@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);
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
if(tile != null && stack.hasTagCompound()) {
tile.machineType = stack.stackTagCompound.getString("machineType");
tile.init();
tile.markChanged();
}
}
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if(!player.capabilities.isCreativeMode) {
harvesters.set(player);
this.dropBlockAsItem(world, x, y, z, meta, 0);
harvesters.set(null);
}
}
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
player.addExhaustion(0.025F);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
Item item = getItemDropped(metadata, world.rand, fortune);
if(item != null) {
ItemStack stack = new ItemStack(item, 1, damageDropped(metadata));
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
if(tile != null) {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setString("machineType", tile.machineType);
}
ret.add(stack);
}
return ret;
}
}

View File

@ -55,7 +55,7 @@ public class CommandDebugChunkLoad extends CommandBase {
}
Object[] data = anvil.loadChunk__Async(sender.getEntityWorld(), cX, cZ);
Chunk chunk = (Chunk) data[0];
//Chunk chunk = (Chunk) data[0];
NBTTagCompound nbt = (NBTTagCompound) data[1];
NBTTagCompound level = nbt.getCompoundTag("Level");
NBTTagList tagList = level.getTagList("TileEntities", 10);

View File

@ -179,6 +179,7 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX * motionMult(), this.motionY * motionMult(), this.motionZ * motionMult()).expand(1.0D, 1.0D, 1.0D));
double nearest = 0.0D;
EntityLivingBase thrower = this.getThrower();
MovingObjectPosition nonPenImpact = null;
for(int j = 0; j < list.size(); ++j) {
Entity entity = (Entity) list.get(j);
@ -192,7 +193,7 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
// if penetration is enabled, run impact for all intersecting entities
if(this.doesPenetrate()) {
this.onImpact(new MovingObjectPosition(entity));
this.onImpact(new MovingObjectPosition(entity, hitMop.hitVec));
} else {
double dist = pos.distanceTo(hitMop.hitVec);
@ -200,6 +201,7 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
if(dist < nearest || nearest == 0.0D) {
hitEntity = entity;
nearest = dist;
nonPenImpact = hitMop;
}
}
}
@ -208,7 +210,7 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
// if not, only run it for the closest MOP
if(!this.doesPenetrate() && hitEntity != null) {
mop = new MovingObjectPosition(hitEntity);
mop = new MovingObjectPosition(hitEntity, nonPenImpact.hitVec);
}
}

View File

@ -0,0 +1,107 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotCraftingOutput;
import com.hbm.inventory.SlotPattern;
import com.hbm.tileentity.machine.TileEntityCustomMachine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerMachineCustom extends Container {
private TileEntityCustomMachine custom;
public ContainerMachineCustom(InventoryPlayer playerInv, TileEntityCustomMachine tile) {
custom = tile;
//Input
this.addSlotToContainer(new Slot(tile, 0, 150, 72));
//Fluid IDs
for(int i = 0; i < tile.inputTanks.length; i++) this.addSlotToContainer(new Slot(tile, 1 + i, 8, 54 + 18 * i));
//Item inputs
if(tile.config.itemInCount > 0) this.addSlotToContainer(new Slot(tile, 4, 8, 72));
if(tile.config.itemInCount > 1) this.addSlotToContainer(new Slot(tile, 5, 26, 72));
if(tile.config.itemInCount > 2) this.addSlotToContainer(new Slot(tile, 6, 44, 72));
if(tile.config.itemInCount > 3) this.addSlotToContainer(new Slot(tile, 7, 8, 90));
if(tile.config.itemInCount > 4) this.addSlotToContainer(new Slot(tile, 8, 26, 90));
if(tile.config.itemInCount > 5) this.addSlotToContainer(new Slot(tile, 9, 44, 90));
//Templates
if(tile.config.itemInCount > 0) this.addSlotToContainer(new SlotPattern(tile, 10, 8, 108));
if(tile.config.itemInCount > 1) this.addSlotToContainer(new SlotPattern(tile, 11, 26, 108));
if(tile.config.itemInCount > 2) this.addSlotToContainer(new SlotPattern(tile, 12, 44, 108));
if(tile.config.itemInCount > 3) this.addSlotToContainer(new SlotPattern(tile, 13, 8, 126));
if(tile.config.itemInCount > 4) this.addSlotToContainer(new SlotPattern(tile, 14, 26, 126));
if(tile.config.itemInCount > 5) this.addSlotToContainer(new SlotPattern(tile, 15, 44, 126));
//Output
if(tile.config.itemOutCount > 0) this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 16, 78, 72));
if(tile.config.itemOutCount > 1) this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 17, 96, 72));
if(tile.config.itemOutCount > 2) this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 18, 114, 72));
if(tile.config.itemOutCount > 3) this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 19, 78, 90));
if(tile.config.itemOutCount > 4) this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 20, 96, 90));
if(tile.config.itemOutCount > 5) this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 21, 114, 90));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 174 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 232));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return custom.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
return null;
}
@Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
//L/R: 0
//M3: 3
//SHIFT: 1
//DRAG: 5
//TODO: shoot whoever at mojang wrote the container code
if(index < 0 || index >= this.inventorySlots.size() || !(this.inventorySlots.get(index) instanceof SlotPattern)) {
return super.slotClick(index, button, mode, player);
}
Slot slot = this.getSlot(index);
index = ((Slot) this.inventorySlots.get(index)).getSlotIndex();
ItemStack ret = null;
ItemStack held = player.inventory.getItemStack();
if(slot.getHasStack())
ret = slot.getStack().copy();
if(button == 1 && mode == 0 && slot.getHasStack()) {
custom.matcher.nextMode(player.worldObj, slot.getStack(), index - 10);
return ret;
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
custom.matcher.initPatternSmart(player.worldObj, slot.getStack(), index - 10);
return ret;
}
}
}

View File

@ -0,0 +1,63 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerMachineCustom;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityCustomMachine;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIMachineCustom extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_custom.png");
private TileEntityCustomMachine custom;
public GUIMachineCustom(InventoryPlayer invPlayer, TileEntityCustomMachine tedf) {
super(new ContainerMachineCustom(invPlayer, tedf));
custom = tedf;
this.xSize = 176;
this.ySize = 256;
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.custom.getInventoryName();
this.fontRendererObj.drawString(name, 68 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float interp, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
int index = i * 3 + j;
if(custom.config.itemInCount <= index) {
drawTexturedModalRect(guiLeft + 7 + j * 18, guiTop + 71 + i * 18, 192 + j * 18, 86 + i * 18, 18, 18);
drawTexturedModalRect(guiLeft + 7 + j * 18, guiTop + 107 + i * 18, 192 + j * 18, 86 + i * 18, 18, 18);
}
if(custom.config.itemOutCount <= index) {
drawTexturedModalRect(guiLeft + 77 + j * 18, guiTop + 71 + i * 18, 192 + j * 18, 86 + i * 18, 18, 18);
}
}
}
for(int i = 0; i < 3; i++) {
if(custom.config.fluidInCount <= i) {
drawTexturedModalRect(guiLeft + 7 + i * 18, guiTop + 17, 192 + i * 18, 32, 18, 54);
}
if(custom.config.fluidOutCount <= i) {
drawTexturedModalRect(guiLeft + 77 + i * 18, guiTop + 17, 192 + i * 18, 32, 18, 36);
}
}
}
}

View File

@ -0,0 +1,127 @@
package com.hbm.inventory.recipes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.FluidStack;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.items.ModItems;
import com.hbm.util.Tuple.Pair;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
public class CustomMachineRecipes extends SerializableRecipe {
public static HashMap<String, List<CustomMachineRecipe>> recipes = new HashMap();
@Override
public void registerDefaults() {
recipes.put("paperPress", new ArrayList() {{
CustomMachineRecipe recipe = new CustomMachineRecipe();
recipe.inputFluids = new FluidStack[] {new FluidStack(Fluids.WATER, 250)};
recipe.inputItems = new AStack[] {new ComparableStack(ModItems.powder_sawdust)};
recipe.outputFluids = new FluidStack[0];
recipe.outputItems = new Pair[] {new Pair(new ItemStack(Items.paper, 3), 1F)};
recipe.duration = 60;
recipe.consumptionPerTick = 10;
add(recipe);
}});
}
@Override
public String getFileName() {
return "hbmCustomMachines.json";
}
@Override
public Object getRecipeObject() {
return recipes;
}
@Override
public void deleteRecipes() {
recipes.clear();
}
@Override
public void readRecipe(JsonElement recipe) {
JsonObject obj = recipe.getAsJsonObject();
String name = obj.get("recipeKey").getAsString();
List<CustomMachineRecipe> list = new ArrayList();
JsonArray array = obj.get("recipes").getAsJsonArray();
for(int i = 0; i < array.size(); i++) {
JsonObject rec = array.get(i).getAsJsonObject();
CustomMachineRecipe recipeInstance = new CustomMachineRecipe();
recipeInstance.inputFluids = this.readFluidArray(rec.get("inputFluids").getAsJsonArray());
recipeInstance.inputItems = this.readAStackArray(rec.get("inputItems").getAsJsonArray());
recipeInstance.outputFluids = this.readFluidArray(rec.get("outputFluids").getAsJsonArray());
recipeInstance.outputItems = this.readItemStackArrayChance(rec.get("outputItems").getAsJsonArray());
recipeInstance.duration = rec.get("duration").getAsInt();
recipeInstance.consumptionPerTick = rec.get("consumptionPerTick").getAsInt();
list.add(recipeInstance);
}
recipes.put(name, list);
}
@Override
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
Entry<String, List<CustomMachineRecipe>> entry = (Entry) recipe;
writer.name("recipeKey").value(entry.getKey());
writer.name("recipes").beginArray();
for(CustomMachineRecipe recipeInstance : entry.getValue()) {
writer.beginObject();
writer.name("inputFluids").beginArray();
for(FluidStack stack : recipeInstance.inputFluids) this.writeFluidStack(stack, writer);
writer.endArray();
writer.name("inputItems").beginArray();
for(AStack stack : recipeInstance.inputItems) this.writeAStack(stack, writer);
writer.endArray();
writer.name("outputFluids").beginArray();
for(FluidStack stack : recipeInstance.outputFluids) this.writeFluidStack(stack, writer);
writer.endArray();
writer.name("outputItems").beginArray();
for(Pair stack : recipeInstance.outputItems) this.writeItemStackChance(stack, writer);
writer.endArray();
writer.name("duration").value(recipeInstance.duration);
writer.name("consumptionPerTick").value(recipeInstance.consumptionPerTick);
writer.endObject();
}
writer.endArray();
}
public static class CustomMachineRecipe {
public FluidStack[] inputFluids;
public AStack[] inputItems;
public FluidStack[] outputFluids;
public Pair<ItemStack, Float>[] outputItems;
public int duration;
public int consumptionPerTick;
}
}

View File

@ -25,6 +25,7 @@ import com.hbm.inventory.material.MatDistribution;
import com.hbm.inventory.recipes.*;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.util.Tuple.Pair;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -62,6 +63,7 @@ public abstract class SerializableRecipe {
recipeHandlers.add(new OutgasserRecipes());
recipeHandlers.add(new CompressorRecipes());
recipeHandlers.add(new MatDistribution());
recipeHandlers.add(new CustomMachineRecipes());
}
public static void initialize() {
@ -166,7 +168,9 @@ public abstract class SerializableRecipe {
writer.endArray(); //end recipe array
writer.endObject(); //final '}'
writer.close();
} catch(Exception ex) { }
} catch(Exception ex) {
ex.printStackTrace();
}
}
public void readRecipeFile(File file) {
@ -243,6 +247,18 @@ public abstract class SerializableRecipe {
return new ItemStack(ModItems.nothing);
}
protected static Pair<ItemStack, Float> readItemStackChance(JsonArray array) {
try {
Item item = (Item) Item.itemRegistry.getObject(array.get(0).getAsString());
int stacksize = array.size() > 2 ? array.get(1).getAsInt() : 1;
int meta = array.size() > 3 ? array.get(2).getAsInt() : 0;
float chance = array.get(array.size() - 1).getAsFloat();
if(item != null) return new Pair(new ItemStack(item, stacksize, meta), chance);
} catch(Exception ex) { }
MainRegistry.logger.error("Error reading stack array " + array.toString() + " - defaulting to NOTHING item!");
return new Pair(new ItemStack(ModItems.nothing), 1F);
}
protected static ItemStack[] readItemStackArray(JsonArray array) {
try {
ItemStack[] items = new ItemStack[array.size()];
@ -253,6 +269,16 @@ public abstract class SerializableRecipe {
return new ItemStack[0];
}
protected static Pair<ItemStack, Float>[] readItemStackArrayChance(JsonArray array) {
try {
Pair<ItemStack, Float>[] items = new Pair[array.size()];
for(int i = 0; i < items.length; i++) { items[i] = readItemStackChance((JsonArray) array.get(i)); }
return items;
} catch(Exception ex) { }
MainRegistry.logger.error("Error reading stack array " + array.toString());
return new Pair[0];
}
protected static void writeItemStack(ItemStack stack, JsonWriter writer) throws IOException {
writer.beginArray();
writer.setIndent("");
@ -263,6 +289,17 @@ public abstract class SerializableRecipe {
writer.setIndent(" ");
}
protected static void writeItemStackChance(Pair<ItemStack, Float> stack, JsonWriter writer) throws IOException {
writer.beginArray();
writer.setIndent("");
writer.value(Item.itemRegistry.getNameForObject(stack.getKey().getItem())); //item name
if(stack.getKey().stackSize != 1 || stack.getKey().getItemDamage() != 0) writer.value(stack.getKey().stackSize); //stack size
if(stack.getKey().getItemDamage() != 0) writer.value(stack.getKey().getItemDamage()); //metadata
writer.value(stack.value); //chance
writer.endArray();
writer.setIndent(" ");
}
protected static FluidStack readFluidStack(JsonArray array) {
try {
FluidType type = Fluids.fromName(array.get(0).getAsString());

View File

@ -0,0 +1,51 @@
package com.hbm.items.block;
import java.util.List;
import java.util.Map.Entry;
import com.hbm.config.CustomMachineConfigJSON;
import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ItemCustomMachine extends ItemBlock {
public ItemCustomMachine(Block block) {
super(block);
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for(Entry<String, MachineConfiguration> entry : CustomMachineConfigJSON.customMachines.entrySet()) {
ItemStack stack = new ItemStack(item);
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setString("machineType", entry.getKey());
list.add(stack);
}
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
if(stack.hasTagCompound()) {
String name = stack.getTagCompound().getString("machineType");
MachineConfiguration conf = CustomMachineConfigJSON.customMachines.get(name);
if(conf != null) {
return conf.localizedName;
}
return "INVALID MACHINE CONTROLLER (" + name + ")";
}
return "INVALID MACHINE CONTROLLER";
}
}

View File

@ -838,6 +838,8 @@ public class MainRegistry {
AnvilRecipes.register();
RefineryRecipes.registerRefinery();
GasCentrifugeRecipes.register();
CustomMachineConfigJSON.initialize();
//the good stuff
SerializableRecipe.registerAllHandlers();

View File

@ -194,6 +194,7 @@ public class TileMappings {
put(TileEntityMachineBAT9000.class, "tileentity_bat9000");
put(TileEntityMachineOrbus.class, "tileentity_orbus");
put(TileEntityGlpyhidSpawner.class, "tileentity_glyphid_spawner");
put(TileEntityCustomMachine.class, "tileentity_custom_machine");
put(TileEntityLoot.class, "tileentity_ntm_loot");
put(TileEntityBobble.class, "tileentity_ntm_bobblehead");

View File

@ -0,0 +1,202 @@
package com.hbm.tileentity.machine;
import com.hbm.config.CustomMachineConfigJSON;
import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration;
import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration.ComponentDefinition;
import com.hbm.inventory.container.ContainerMachineCustom;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIMachineCustom;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCustomMachine extends TileEntityMachineBase implements IGUIProvider {
public String machineType;
public MachineConfiguration config;
public long power;
public int progress;
public FluidTank[] inputTanks;
public FluidTank[] outputTanks;
public ModulePatternMatcher matcher;
public int structureCheckDelay;
public boolean structureOK = false;
public TileEntityCustomMachine() {
/*
* 0: Battery
* 1-3: Fluid IDs
* 4-9: Inputs
* 10-15: Template
* 16-21: Output
*/
super(22);
}
public void init() {
MachineConfiguration config = CustomMachineConfigJSON.customMachines.get(this.machineType);
if(config != null) {
this.config = config;
inputTanks = new FluidTank[config.fluidInCount];
for(int i = 0; i < inputTanks.length; i++) inputTanks[i] = new FluidTank(Fluids.NONE, config.fluidInCap);
outputTanks = new FluidTank[config.fluidOutCount];
for(int i = 0; i < outputTanks.length; i++) outputTanks[i] = new FluidTank(Fluids.NONE, config.fluidOutCap);
matcher = new ModulePatternMatcher(config.itemInCount);
} else {
worldObj.func_147480_a(xCoord, yCoord, zCoord, false);
}
}
@Override
public String getName() {
return config != null ? config.localizedName : "INVALID";
}
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(config == null) {
worldObj.func_147480_a(xCoord, yCoord, zCoord, false);
return;
}
this.structureCheckDelay--;
if(this.structureCheckDelay <= 0) this.checkStructure();
NBTTagCompound data = new NBTTagCompound();
data.setString("type", this.machineType);
data.setLong("power", power);
data.setInteger("progress", progress);
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].writeToNBT(data, "i" + i);
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].writeToNBT(data, "o" + i);
this.matcher.writeToNBT(data);
this.networkPack(data, 50);
}
}
public boolean checkStructure() {
this.structureCheckDelay = 300;
this.structureOK = false;
if(this.config == null) return false;
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
for(ComponentDefinition comp : config.components) {
/* vvv precisely the same method used for defining ports vvv */
int x = xCoord - dir.offsetX * comp.x + rot.offsetX * comp.x;
int y = yCoord + comp.y;
int z = zCoord - dir.offsetZ * comp.z + rot.offsetZ * comp.z;
/* but for EW directions it just stops working entirely */
/* there is absolutely zero reason why this should be required */
if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
x = xCoord + dir.offsetZ * comp.z - rot.offsetZ * comp.z;
z = zCoord + dir.offsetX * comp.x - rot.offsetX * comp.x;
}
/* i wholeheartedly believe it is the computer who is wrong here */
Block b = worldObj.getBlock(x, y, z);
if(b != comp.block) return false;
int meta = worldObj.getBlockMetadata(x, y, z);
if(!comp.allowedMetas.contains(meta)) return false;
}
this.structureOK = true;
return true;
}
public void buildStructure() {
if(this.config == null) return;
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
for(ComponentDefinition comp : config.components) {
int x = xCoord - dir.offsetX * comp.x + rot.offsetX * comp.x;
int y = yCoord + comp.y;
int z = zCoord - dir.offsetZ * comp.z + rot.offsetZ * comp.z;
if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
x = xCoord + dir.offsetZ * comp.z - rot.offsetZ * comp.z;
z = zCoord + dir.offsetX * comp.x - rot.offsetX * comp.x;
}
worldObj.setBlock(x, y, z, comp.block, (int) comp.allowedMetas.toArray()[0], 3);
}
}
@Override
public void networkUnpack(NBTTagCompound nbt) {
this.machineType = nbt.getString("type");
if(this.config == null) this.init();
this.power = nbt.getLong("power");
this.progress = nbt.getInteger("progress");
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].readFromNBT(nbt, "i" + i);
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i);
this.matcher.readFromNBT(nbt);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
this.machineType = nbt.getString("machineType");
this.init();
super.readFromNBT(nbt);
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].readFromNBT(nbt, "i" + i);
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i);
this.matcher.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
nbt.setString("machineType", machineType);
super.writeToNBT(nbt);
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].writeToNBT(nbt, "i" + i);
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].writeToNBT(nbt, "o" + i);
this.matcher.writeToNBT(nbt);
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
if(this.config == null) return null;
return new ContainerMachineCustom(player.inventory, this);
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
if(this.config == null) return null;
return new GUIMachineCustom(player.inventory, this);
}
}

View File

@ -139,7 +139,7 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("items", 10);
power = nbt.getInteger("power");
power = nbt.getLong("power");
heat = nbt.getInteger("heat");
slots = new ItemStack[getSizeInventory()];
@ -157,16 +157,14 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("power", (short) (power));
nbt.setInteger("heat", (short) (heat));
nbt.setLong("power", power);
nbt.setInteger("heat", heat);
NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.length; i++)
{
if(slots[i] != null)
{
for(int i = 0; i < slots.length; i++) {
if(slots[i] != null) {
NBTTagCompound nbt1 = new NBTTagCompound();
nbt1.setByte("slot", (byte)i);
nbt1.setByte("slot", (byte) i);
slots[i].writeToNBT(nbt1);
list.appendTag(nbt1);
}
@ -175,9 +173,9 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
}
@Override
public int[] getAccessibleSlotsFromSide(int p_94128_1_){
return slot_io;
}
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
return slot_io;
}
@Override
public boolean canInsertItem(int i, ItemStack itemStack, int j) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB