Too Many Molds

there is toxic black mold growing in my brain
This commit is contained in:
Boblet 2022-09-28 16:54:42 +02:00
parent 35c9833e69
commit 4ee7e680fb
13 changed files with 259 additions and 51 deletions

View File

@ -143,7 +143,7 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc
text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noCast"));
} else if(cast.slots[0].getItem() == ModItems.mold){
Mold mold = ((ItemMold) cast.slots[0].getItem()).getMold(cast.slots[0]);
text.add(EnumChatFormatting.BLUE + I18nUtil.resolveKey("shape." + mold.shape.name().toLowerCase()) + " x" + mold.amount);
text.add(EnumChatFormatting.BLUE + mold.getTitle());
}
if(cast.type != null && cast.amount > 0) {

View File

@ -1,6 +1,10 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.lib.Library;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityFoundryOutlet;
@ -11,9 +15,11 @@ 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.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
@ -63,6 +69,39 @@ public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor {
return new TileEntityFoundryOutlet();
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) {
AxisAlignedBB aabb = null;
int meta = world.getBlockMetadata(x, y, z);
if(meta == 2) aabb = AxisAlignedBB.getBoundingBox(x + 0.625D, y, z + 0.3125D, x + 1D, y + 0.5D, z + 0.6875D);
if(meta == 3) aabb = AxisAlignedBB.getBoundingBox(x + 0D, y, z + 0.3125D, x + 0.375D, y + 0.5D, z + 0.6875D);
if(meta == 4) aabb = AxisAlignedBB.getBoundingBox(x + 0.3125D, y, z + 0.625D, x + 0.6875D, y + 0.5D, z + 1D);
if(meta == 5) aabb = AxisAlignedBB.getBoundingBox(x + 0.3125D, y, z + 0D, x + 0.6875D, y + 0.5D, z + 0.375D);
if(aabb != null && entityBounding.intersectsWith(aabb)) {
list.add(aabb);
}
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
setBlockBoundsBasedOnState(world, x, y, z);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == 2) this.setBlockBounds(0.625F, 0F, 0.3125F, 1F, 0.5F, 0.6875F);
if(meta == 3) this.setBlockBounds(0F, 0F, 0.3125F, 0.375F, 0.5F, 0.6875F);
if(meta == 4) this.setBlockBounds(0.3125F, 0F, 0.625F, 0.6875F, 0.5F, 1F);
if(meta == 5) this.setBlockBounds(0.3125F, 0F, 0F, 0.6875F, 0.5F, 0.375F);
}
@Override public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { return false; }
@Override public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { return stack; }

View File

@ -43,8 +43,8 @@ public class Mats {
public static final int _AS = 30;
//Vanilla and vanilla-like
public static final NTMMaterial MAT_STONE = makeSmeltable(_VS + 00, df("Stone"), 0x4D2F23);
public static final NTMMaterial MAT_COAL = makeAdditive( 1400, COAL, 0x583434);
public static final NTMMaterial MAT_STONE = makeSmeltable(_VS + 00, df("Stone"), 0x4D2F23).omitAutoGen();
public static final NTMMaterial MAT_COAL = makeAdditive( 1400, COAL, 0x583434).omitAutoGen();
public static final NTMMaterial MAT_LIGNITE = makeAdditive( 1401, LIGNITE, 0x715444);
public static final NTMMaterial MAT_COALCOKE = makeAdditive( 1410, COALCOKE, 0);
public static final NTMMaterial MAT_PETCOKE = makeAdditive( 1411, PETCOKE, 0);
@ -53,12 +53,14 @@ public class Mats {
public static final NTMMaterial MAT_IRON = makeSmeltable(2600, IRON, 0xFFA259).omitAutoGen();
public static final NTMMaterial MAT_GOLD = makeSmeltable(7900, GOLD, 0xE8D754).omitAutoGen();
public static final NTMMaterial MAT_REDSTONE = makeSmeltable(_VS + 01, REDSTONE, 0x7A0300).omitAutoGen();
public static final NTMMaterial MAT_OBSIDIAN = makeSmeltable(_VS + 02, df("Obsidian"), 0x4D2F23).omitAutoGen();
//Radioactive
public static final NTMMaterial MAT_URANIUM = makeSmeltable(9200, U, 0).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK);
public static final NTMMaterial MAT_THORIUM = makeSmeltable(9232, TH232, 0).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK);
public static final NTMMaterial MAT_PLUTONIUM = makeSmeltable(9400, PU, 0).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK);
public static final NTMMaterial MAT_RADIUM = makeSmeltable(8826, RA226, 0).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK);
public static final NTMMaterial MAT_SCHRABIDIUM = makeSmeltable(12626, SA326, 0).setShapes(NUGGET, WIRE, BILLET, INGOT, DUST, PLATE, BLOCK);
//Base metals
public static final NTMMaterial MAT_TITANIUM = makeSmeltable(2200, TI, 0xA99E79).setShapes(INGOT, DUST, PLATE, BLOCK);
@ -83,6 +85,7 @@ public class Mats {
public static final NTMMaterial MAT_STAR = makeSmeltable(_AS + 5, STAR, 0).setShapes(INGOT, DUST, BLOCK);
public static final NTMMaterial MAT_TCALLOY = makeSmeltable(_AS + 6, TCALLOY, 0).setShapes(INGOT, DUST);
public static final NTMMaterial MAT_MAGTUNG = makeSmeltable(_AS + 7, MAGTUNG, 0).setShapes(INGOT, DUST, BLOCK);
public static final NTMMaterial MAT_CMB = makeSmeltable(_AS + 8, CMB, 0).setShapes(INGOT, DUST, PLATE, BLOCK);
public static NTMMaterial make(int id, DictFrame dict) {
return new NTMMaterial(id, dict);

View File

@ -1,10 +1,14 @@
package com.hbm.items.machine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.MaterialShapes;
import com.hbm.inventory.material.NTMMaterial;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.util.I18nUtil;
@ -17,27 +21,70 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.OreDictionary;
public class ItemMold extends Item {
public List<Mold> molds = new ArrayList();
public List<Mold> molds = new ArrayList(); //molds in "pretty" order, variable between versions
public HashMap<Integer, Mold> moldById = new HashMap(); //molds by their static ID -> stack item damage
public ItemMold() {
this.molds.add(new Mold(0, 0, "nugget", MaterialShapes.NUGGET));
this.molds.add(new Mold(1, 0, "billet", MaterialShapes.BILLET));
this.molds.add(new Mold(2, 0, "ingot", MaterialShapes.INGOT));
this.molds.add(new Mold(3, 0, "plate", MaterialShapes.PLATE));
this.molds.add(new Mold(4, 0, "wire", MaterialShapes.WIRE, 8));
this.molds.add(new Mold(5, 1, "ingots", MaterialShapes.INGOT, 9));
this.molds.add(new Mold(6, 1, "plates", MaterialShapes.PLATE, 9));
this.molds.add(new Mold(7, 1, "block", MaterialShapes.BLOCK));
int S = 0;
int L = 0;
registerMold(new MoldShape( 0, S, "nugget", MaterialShapes.NUGGET));
registerMold(new MoldShape( 1, S, "billet", MaterialShapes.BILLET));
registerMold(new MoldShape( 2, S, "ingot", MaterialShapes.INGOT));
registerMold(new MoldShape( 3, S, "plate", MaterialShapes.PLATE));
registerMold(new MoldWire( 4, S, "wire"));
registerMold(new MoldMulti( 5, S, "blade", MaterialShapes.INGOT.q(3),
Mats.MAT_TITANIUM, new ItemStack(ModItems.blade_titanium),
Mats.MAT_TUNGSTEN, new ItemStack(ModItems.blade_tungsten)));
registerMold(new MoldMulti( 6, S, "blades", MaterialShapes.INGOT.q(4),
Mats.MAT_GOLD, new ItemStack(ModItems.blades_gold),
Mats.MAT_ALUMINIUM, new ItemStack(ModItems.blades_aluminium),
Mats.MAT_IRON, new ItemStack(ModItems.blades_iron),
Mats.MAT_STEEL, new ItemStack(ModItems.blades_steel),
Mats.MAT_TITANIUM, new ItemStack(ModItems.blades_titanium),
Mats.MAT_ALLOY, new ItemStack(ModItems.blades_advanced_alloy),
Mats.MAT_CMB, new ItemStack(ModItems.blades_combine_steel),
Mats.MAT_SCHRABIDIUM, new ItemStack(ModItems.blades_schrabidium)));
registerMold(new MoldMulti( 7, S, "blades", MaterialShapes.INGOT.q(4),
Mats.MAT_STONE, new ItemStack(ModItems.stamp_stone_flat),
Mats.MAT_IRON, new ItemStack(ModItems.stamp_iron_flat),
Mats.MAT_STEEL, new ItemStack(ModItems.stamp_steel_flat),
Mats.MAT_TITANIUM, new ItemStack(ModItems.stamp_titanium_flat),
Mats.MAT_OBSIDIAN, new ItemStack(ModItems.stamp_obsidian_flat),
Mats.MAT_SCHRABIDIUM, new ItemStack(ModItems.stamp_schrabidium_flat)));
registerMold(new MoldMulti( 8, S, "hull_small", MaterialShapes.INGOT.q(2),
Mats.MAT_STEEL, new ItemStack(ModItems.hull_small_steel),
Mats.MAT_ALUMINIUM, new ItemStack(ModItems.hull_small_aluminium)));
registerMold(new MoldMulti( 9, L, "hull_big", MaterialShapes.INGOT.q(6),
Mats.MAT_STEEL, new ItemStack(ModItems.hull_big_steel),
Mats.MAT_ALUMINIUM, new ItemStack(ModItems.hull_big_aluminium),
Mats.MAT_TITANIUM, new ItemStack(ModItems.hull_big_titanium)));
registerMold(new MoldShape( 10, L, "ingots", MaterialShapes.INGOT, 9));
registerMold(new MoldShape( 11, L, "plates", MaterialShapes.PLATE, 9));
registerMold(new MoldShape( 12, L, "block", MaterialShapes.BLOCK));
registerMold(new MoldSingle( 13, L, "pipes", new ItemStack(ModItems.pipes_steel), Mats.MAT_STEEL, MaterialShapes.BLOCK.q(3)));
}
public void registerMold(Mold mold) {
this.molds.add(mold);
this.moldById.put(mold.id, mold);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < molds.size(); i++) {
list.add(new ItemStack(item, 1, i));
Mold mold = molds.get(i);
list.add(new ItemStack(item, 1, mold.id));
}
}
@ -56,7 +103,11 @@ public class ItemMold extends Item {
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return this.icons[Math.abs(meta % icons.length)];
Mold mold = this.moldById.get(meta);
if(mold != null)
return this.icons[mold.order];
return this.icons[0];
}
/*@Override
@ -68,40 +119,171 @@ public class ItemMold extends Item {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
Mold mold = getMold(stack);
list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("shape." + mold.shape.name().toLowerCase()) + " x" + mold.amount);
list.add(EnumChatFormatting.YELLOW + mold.getTitle());
if(mold.size == 0) list.add(EnumChatFormatting.GOLD + I18nUtil.resolveKey(ModBlocks.foundry_mold.getUnlocalizedName() + ".name"));
if(mold.size == 1) list.add(EnumChatFormatting.RED + I18nUtil.resolveKey(ModBlocks.foundry_basin.getUnlocalizedName() + ".name"));
}
public Mold getMold(ItemStack stack) {
int meta = Math.abs(stack.getItemDamage() % molds.size());
Mold mold = molds.get(meta);
return mold;
Mold mold = moldById.get(stack.getItemDamage());
return mold != null ? mold : molds.get(0);
}
public static int nextOrder = 0;
public class Mold {
public MaterialShapes shape;
public int amount;
public abstract class Mold {
public int order;
public int id;
public int size;
public String name;
public Mold(int id, int size, String name, MaterialShapes shape) {
this(id, size, name, shape, 1);
}
public Mold(int id, int size, String name, MaterialShapes shape, int amount) {
public Mold(int id, int size, String name) {
this.order = nextOrder++;
this.id = id;
this.size = size;
this.shape = shape;
this.amount = amount;
this.name = name;
}
public abstract ItemStack getOutput(NTMMaterial mat);
public abstract int getCost();
public abstract String getTitle();
}
public class MoldShape extends Mold {
MaterialShapes shape;
int amount;
public MoldShape(int id, int size, String name, MaterialShapes shape) {
this(id, size, name, shape, 1);
}
public MoldShape(int id, int size, String name, MaterialShapes shape, int amount) {
super(id, size, name);
this.shape = shape;
this.amount = amount;
}
@Override
public ItemStack getOutput(NTMMaterial mat) {
for(String name : mat.names) {
String od = shape.name().toLowerCase() + name;
List<ItemStack> ores = OreDictionary.getOres(od);
if(!ores.isEmpty()) {
return ores.get(0);
}
}
return null;
}
@Override
public int getCost() {
return shape.q(amount);
}
@Override
public String getTitle() {
return I18nUtil.resolveKey("shape." + shape.name().toLowerCase()) + " x" + amount;
}
}
public class MoldWire extends Mold {
public MoldWire(int id, int size, String name) {
super(id, size, name);
}
@Override
public ItemStack getOutput(NTMMaterial mat) {
if(mat == Mats.MAT_ALUMINIUM) return new ItemStack(ModItems.wire_aluminium, 8);
if(mat == Mats.MAT_ALLOY) return new ItemStack(ModItems.wire_advanced_alloy, 8);
if(mat == Mats.MAT_COPPER) return new ItemStack(ModItems.wire_copper, 8);
if(mat == Mats.MAT_GOLD) return new ItemStack(ModItems.wire_gold, 8);
if(mat == Mats.MAT_MAGTUNG) return new ItemStack(ModItems.wire_magnetized_tungsten, 8);
if(mat == Mats.MAT_MINGRADE) return new ItemStack(ModItems.wire_red_copper, 8);
if(mat == Mats.MAT_SCHRABIDIUM) return new ItemStack(ModItems.wire_schrabidium, 8);
if(mat == Mats.MAT_TUNGSTEN) return new ItemStack(ModItems.wire_tungsten, 8);
return null;
}
@Override
public int getCost() {
return MaterialShapes.WIRE.q(8);
}
@Override
public String getTitle() {
return I18nUtil.resolveKey("shape." + MaterialShapes.WIRE.name().toLowerCase()) + " x8";
}
}
/* because why not */
public class MoldSingle extends Mold {
ItemStack out;
NTMMaterial mat;
int amount;
public MoldSingle(int id, int size, String name, ItemStack out, NTMMaterial mat, int amount) {
super(id, size, name);
this.out = out;
this.mat = mat;
this.amount = amount;
}
@Override
public ItemStack getOutput(NTMMaterial mat) {
return this.mat == mat ? out.copy() : null;
}
@Override
public int getCost() {
return amount;
}
@Override
public String getTitle() {
return out.getDisplayName() + " x" + this.amount;
}
}
/* not so graceful but it does the job and it does it well */
public class MoldMulti extends Mold {
HashMap<NTMMaterial, ItemStack> map = new HashMap();
int amount;
public MoldMulti(int id, int size, String name, int amount, Object... inputs) {
super(id, size, name);
this.amount = amount;
for(int i = 0; i < inputs.length; i += 2) {
map.put((NTMMaterial) inputs[i], (ItemStack) inputs[i + 1]);
}
}
@Override
public ItemStack getOutput(NTMMaterial mat) {
ItemStack out = this.map.get(mat);
if(out != null)
return out.copy();
return out;
}
@Override
public int getCost() {
return amount;
}
@Override
public String getTitle() {
return I18nUtil.resolveKey("shape." + name) + " x" + this.amount;
}
}
}

View File

@ -2,7 +2,6 @@ package com.hbm.render.block;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.machine.FoundryChannel;
import com.hbm.blocks.machine.FoundryOutlet;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

View File

@ -1,7 +1,5 @@
package com.hbm.tileentity.machine;
import java.util.List;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemMold;
@ -14,10 +12,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
/**
* Thank god we have a base class now. Now with documentation and as little redundtand crap in the child classes as possible.
* Thank god we have a base class now. Now with documentation and as little redundant crap in the child classes as possible.
* @author hbm
*
*/
@ -48,14 +45,10 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase
if(cooloff <= 0) {
this.amount = 0;
for(String name : this.type.names) {
String od = mold.shape.name().toLowerCase() + name;
List<ItemStack> ores = OreDictionary.getOres(od);
if(!ores.isEmpty()) {
slots[1] = ores.get(0).copy();
slots[1].stackSize = mold.amount;
}
ItemStack out = mold.getOutput(type);
if(out != null) {
slots[1] = out.copy();
}
cooloff = 100;
@ -101,15 +94,7 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase
Mold mold = this.getInstalledMold();
if(mold == null) return false;
for(String name : stack.material.names) {
String od = mold.shape.name().toLowerCase() + name;
if(!OreDictionary.getOres(od).isEmpty()) {
return true; //at least one block for this material? return TRUE
}
}
return false; //no OD match -> no pouring
return mold.getOutput(stack.material) != null; //no OD match -> no pouring
}
/** Returns an integer determining the mold size, 0 for small molds and 1 for the basin */

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B