foundry fixes and improvements

This commit is contained in:
Bob 2022-10-29 18:23:48 +02:00
parent 08c9f4285c
commit 834f0d294b
16 changed files with 116 additions and 37 deletions

View File

@ -1580,7 +1580,7 @@ public class ModBlocks {
lamp_demon = new DemonLamp().setBlockName("lamp_demon").setStepSound(Block.soundTypeMetal).setCreativeTab(MainRegistry.blockTab).setLightLevel(1F).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_demon");
reinforced_stone = new BlockGeneric(Material.rock).setBlockName("reinforced_stone").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(3000.0F).setBlockTextureName(RefStrings.MODID + ":reinforced_stone");
concrete_smooth = new BlockGeneric(Material.rock).setBlockName("concrete_smooth").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(4000.0F).setBlockTextureName(RefStrings.MODID + ":concrete");
concrete_smooth = new BlockRadResistant(Material.rock).setBlockName("concrete_smooth").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(4000.0F).setBlockTextureName(RefStrings.MODID + ":concrete");
concrete_colored = new BlockConcreteColored(Material.rock).setBlockName("concrete_colored").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(4000.0F).setBlockTextureName(RefStrings.MODID + ":concrete");
concrete = new BlockGeneric(Material.rock).setBlockName("concrete").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(4000.0F).setBlockTextureName(RefStrings.MODID + ":concrete_tile");
concrete_asbestos = new BlockGeneric(Material.rock).setBlockName("concrete_asbestos").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(4000.0F).setBlockTextureName(RefStrings.MODID + ":concrete_asbestos");

View File

@ -27,7 +27,7 @@ public class BlockDepth extends Block implements ITooltipProvider {
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IDepthRockTool) {
if(((IDepthRockTool)player.getHeldItem().getItem()).canBreakRock(world, player, player.getHeldItem(), this, x, y, z))
return (float) (1D / 100D);
return (float) (1D / 50D);
}
return super.getPlayerRelativeBlockHardness(player, world, x, y, z);

View File

@ -0,0 +1,32 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.IRadResistantBlock;
import com.hbm.handler.radiation.ChunkRadiationHandlerNT;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
public class BlockRadResistant extends Block implements IRadResistantBlock {
public BlockRadResistant(Material mat) {
super(mat);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
ChunkRadiationHandlerNT.markChunkForRebuild(world, x, y, z);
super.onBlockAdded(world, x, y, z);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
ChunkRadiationHandlerNT.markChunkForRebuild(world, x, y, z);
super.breakBlock(world, x, y, z, b, meta);
}
@Override
public int getResistance() {
return 1;
}
}

View File

@ -23,7 +23,7 @@ public class ScrapsCraftingHandler implements IRecipe {
if(mat != null) return false;
mat = ItemScraps.getMats(stack);
if(mat.amount > 2) return false;
if(mat.amount < 2) return false;
}
return mat != null;
@ -41,7 +41,7 @@ public class ScrapsCraftingHandler implements IRecipe {
if(mat != null) return null;
mat = ItemScraps.getMats(stack);
if(mat.amount > 2) return null;
if(mat.amount < 2) return null;
}
if(mat == null) return null;

View File

@ -12,7 +12,7 @@ import net.minecraftforge.event.world.WorldEvent;
public class ChunkRadiationManager {
public static ChunkRadiationHandler proxy = new ChunkRadiationHandlerSimple();
public static ChunkRadiationHandler proxy = new ChunkRadiationHandlerNT(); //new ChunkRadiationHandlerSimple();
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {

View File

@ -4,6 +4,7 @@ import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerCrucible;
@ -76,7 +77,7 @@ public class GUICrucible extends GuiInfoContainer {
list.add(EnumChatFormatting.RED + "Empty");
for(MaterialStack sta : stack) {
list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(sta.material.getUnlocalizedName()) + ": " + Mats.formatAmount(sta.amount));
list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(sta.material.getUnlocalizedName()) + ": " + Mats.formatAmount(sta.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
}
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + x, guiTop + y, 36, 81, mouseX, mouseY, list);

View File

@ -48,13 +48,13 @@ public class Mats {
//Vanilla and vanilla-like
public static final NTMMaterial MAT_STONE = makeSmeltable(_VS + 00, df("Stone"), 0x4D2F23).omitAutoGen();
public static final NTMMaterial MAT_CARBON = makeAdditive( 1499, df("Carbon"), 0xD0D0D0).omitAutoGen();
public static final NTMMaterial MAT_COAL = make( 1400, COAL) .setConversion(MAT_CARBON, 0.8D).omitAutoGen();
public static final NTMMaterial MAT_LIGNITE = make( 1401, LIGNITE) .setConversion(MAT_CARBON, 0.5D);
public static final NTMMaterial MAT_COALCOKE = make( 1410, COALCOKE) .setConversion(MAT_CARBON, 0.8D);
public static final NTMMaterial MAT_PETCOKE = make( 1411, PETCOKE) .setConversion(MAT_CARBON, 0.8D);
public static final NTMMaterial MAT_LIGCOKE = make( 1412, LIGCOKE) .setConversion(MAT_CARBON, 0.8D);
public static final NTMMaterial MAT_GRAPHITE = make( 1420, GRAPHITE) .setConversion(MAT_CARBON, 1D);
public static final NTMMaterial MAT_CARBON = makeAdditive( 1499, df("Carbon"), 0x808080).omitAutoGen();
public static final NTMMaterial MAT_COAL = make( 1400, COAL) .setConversion(MAT_CARBON, 3, 1).omitAutoGen();
public static final NTMMaterial MAT_LIGNITE = make( 1401, LIGNITE) .setConversion(MAT_CARBON, 4, 1);
public static final NTMMaterial MAT_COALCOKE = make( 1410, COALCOKE) .setConversion(MAT_CARBON, 2, 1);
public static final NTMMaterial MAT_PETCOKE = make( 1411, PETCOKE) .setConversion(MAT_CARBON, 2, 1);
public static final NTMMaterial MAT_LIGCOKE = make( 1412, LIGCOKE) .setConversion(MAT_CARBON, 2, 1);
public static final NTMMaterial MAT_GRAPHITE = make( 1420, GRAPHITE) .setConversion(MAT_CARBON, 1, 1);
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, 0xFF1000).omitAutoGen();
@ -117,7 +117,7 @@ public class Mats {
public static final NTMMaterial MAT_MAGTUNG = makeSmeltable(_AS + 8, MAGTUNG, 0x22A2A2).setShapes(INGOT, DUST, BLOCK);
public static final NTMMaterial MAT_CMB = makeSmeltable(_AS + 9, CMB, 0x6F6FB4).setShapes(INGOT, DUST, PLATE, BLOCK);
public static final NTMMaterial MAT_FLUX = makeAdditive(_AS + 10, df("Flux"), 0xDECCAD).setShapes(DUST);
public static final NTMMaterial MAT_SLAG = makeAdditive(_AS + 11, SLAG, 0x6C6562).setShapes(BLOCK);
public static final NTMMaterial MAT_SLAG = makeSmeltable(_AS + 11, SLAG, 0x6C6562).setShapes(BLOCK);
public static NTMMaterial make(int id, DictFrame dict) {
return new NTMMaterial(id, dict);
@ -183,7 +183,7 @@ public class Mats {
public static List<MaterialStack> getSmeltingMaterialsFromItem(ItemStack stack) {
List<MaterialStack> baseMats = getMaterialsFromItem(stack);
List<MaterialStack> smelting = new ArrayList();
baseMats.forEach(x -> smelting.add(new MaterialStack(x.material.smeltsInto, (int) (x.amount * x.material.smeltingRatio))));
baseMats.forEach(x -> smelting.add(new MaterialStack(x.material.smeltsInto, (int) (x.amount * x.material.convOut / x.material.convIn))));
return smelting;
}
@ -202,7 +202,12 @@ public class Mats {
}
}
public static String formatAmount(int amount) {
public static String formatAmount(int amount, boolean showInMb) {
if(showInMb) {
return (amount * 2) + "mB";
}
String format = "";
int blocks = amount / BLOCK.q(1);
@ -213,10 +218,10 @@ public class Mats {
amount -= NUGGET.q(nuggets);
int quanta = amount;
if(blocks > 0) format += (blocks == 1 ? I18nUtil.resolveKey("matshape.block", blocks) : I18nUtil.resolveKey("matshape.blocks", blocks));
if(ingots > 0) format += (ingots == 1 ? I18nUtil.resolveKey("matshape.ingot", ingots) : I18nUtil.resolveKey("matshape.ingots", ingots));
if(nuggets > 0) format += (nuggets == 1 ? I18nUtil.resolveKey("matshape.nugget", nuggets) : I18nUtil.resolveKey("matshape.nuggets", nuggets));
if(quanta > 0) format += (quanta == 1 ? I18nUtil.resolveKey("matshape.quantum", quanta) : I18nUtil.resolveKey("matshape.quanta", quanta));
if(blocks > 0) format += (blocks == 1 ? I18nUtil.resolveKey("matshape.block", blocks) : I18nUtil.resolveKey("matshape.blocks", blocks)) + " ";
if(ingots > 0) format += (ingots == 1 ? I18nUtil.resolveKey("matshape.ingot", ingots) : I18nUtil.resolveKey("matshape.ingots", ingots)) + " ";
if(nuggets > 0) format += (nuggets == 1 ? I18nUtil.resolveKey("matshape.nugget", nuggets) : I18nUtil.resolveKey("matshape.nuggets", nuggets)) + " ";
if(quanta > 0) format += (quanta == 1 ? I18nUtil.resolveKey("matshape.quantum", quanta) : I18nUtil.resolveKey("matshape.quanta", quanta)) + " ";
return format.trim();
}

View File

@ -18,7 +18,8 @@ public class NTMMaterial {
public int moltenColor = 0xFF4A00;
public NTMMaterial smeltsInto;
public double smeltingRatio;
public int convIn;
public int convOut;
public NTMMaterial(int id, DictFrame dict) {
@ -26,7 +27,8 @@ public class NTMMaterial {
this.id = id;
this.smeltsInto = this;
this.smeltingRatio = 1.0D;
this.convIn = 1;
this.convOut = 1;
for(String name : dict.mats) {
Mats.matByName.put(name, this);
@ -40,9 +42,10 @@ public class NTMMaterial {
return "hbmmat." + this.names[0].toLowerCase();
}
public NTMMaterial setConversion(NTMMaterial mat, double mult) {
public NTMMaterial setConversion(NTMMaterial mat, int in, int out) {
this.smeltsInto = mat;
this.smeltingRatio = mult;
this.convIn = in;
this.convOut = out;
return this;
}

View File

@ -219,17 +219,18 @@ public class CrucibleRecipes extends SerializableRecipe {
HashMap<AStack, List<ItemStack>> map = new HashMap();
for(NTMMaterial material : Mats.orderedList) {
double mult = material.smeltingRatio;
material = material.smeltsInto;
int in = material.convIn;
int out = material.convOut;
NTMMaterial convert = material.smeltsInto;
for(MaterialShapes shape : MaterialShapes.allShapes) {
//TODO: buffer these
String name = shape.toString().toLowerCase() + material.names[0];
String name = shape.name() + material.names[0];
List<ItemStack> ores = OreDictionary.getOres(name);
if(!ores.isEmpty()) {
List<ItemStack> stacks = new ArrayList();
stacks.add(ItemScraps.create(new MaterialStack(material, (int) (shape.q(1) * mult))));
stacks.add(ItemScraps.create(new MaterialStack(convert, (int) (shape.q(1) * out / in))));
map.put(new OreDictStack(name), stacks);
}
}

View File

@ -2,6 +2,8 @@ package com.hbm.items.machine;
import java.util.List;
import org.lwjgl.input.Keyboard;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.inventory.recipes.CrucibleRecipes;
@ -42,13 +44,13 @@ public class ItemCrucibleTemplate extends Item {
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("info.template_out_p"));
for(MaterialStack out : recipe.output) {
list.add(I18nUtil.resolveKey(out.material.getUnlocalizedName()) + ": " + Mats.formatAmount(out.amount));
list.add(I18nUtil.resolveKey(out.material.getUnlocalizedName()) + ": " + Mats.formatAmount(out.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
}
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("info.template_in_p"));
for(MaterialStack in : recipe.input) {
list.add(I18nUtil.resolveKey(in.material.getUnlocalizedName()) + ": " + Mats.formatAmount(in.amount));
list.add(I18nUtil.resolveKey(in.material.getUnlocalizedName()) + ": " + Mats.formatAmount(in.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
}
}
}

View File

@ -2,12 +2,15 @@ package com.hbm.items.machine;
import java.util.List;
import org.lwjgl.input.Keyboard;
import com.hbm.inventory.material.MaterialShapes;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.items.ModItems;
import com.hbm.util.I18nUtil;
import com.hbm.inventory.material.NTMMaterial;
import com.hbm.inventory.material.NTMMaterial.SmeltingBehavior;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -27,7 +30,9 @@ public class ItemScraps extends Item {
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for(NTMMaterial mat : Mats.orderedList) {
list.add(new ItemStack(item, 1, mat.id));
if(mat.smeltable == SmeltingBehavior.SMELTABLE || mat.smeltable == SmeltingBehavior.ADDITIVE) {
list.add(new ItemStack(item, 1, mat.id));
}
}
}
@ -36,7 +41,7 @@ public class ItemScraps extends Item {
MaterialStack contents = getMats(stack);
if(contents != null) {
list.add(I18nUtil.resolveKey(contents.material.getUnlocalizedName()) + ", " + Mats.formatAmount(contents.amount));
list.add(I18nUtil.resolveKey(contents.material.getUnlocalizedName()) + ", " + Mats.formatAmount(contents.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
}
}

View File

@ -118,7 +118,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
tryRecipe();
/* pour wasste stack */
/* pour waste stack */
if(!this.wasteStack.isEmpty()) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();

View File

@ -6,16 +6,19 @@ import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.material.MaterialShapes;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.Mats.MaterialStack;
import api.hbm.block.ICrucibleAcceptor;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFoundryChannel extends TileEntityFoundryBase {
public int nextUpdate;
public int lastFlow = 0;
@Override
public void updateEntity() {
@ -31,10 +34,14 @@ public class TileEntityFoundryChannel extends TileEntityFoundryBase {
if(nextUpdate <= 0 && this.amount > 0 && this.type != null) {
boolean hasOp = false;
nextUpdate = worldObj.rand.nextInt(6) + 5;
nextUpdate = 5;
List<Integer> ints = new ArrayList() {{ add(2); add(3); add(4); add(5); }};
Collections.shuffle(ints);
if(lastFlow > 0) {
ints.remove((Integer) this.lastFlow);
ints.add(this.lastFlow);
}
for(Integer i : ints) {
ForgeDirection dir = ForgeDirection.getOrientation(i);
@ -68,7 +75,9 @@ public class TileEntityFoundryChannel extends TileEntityFoundryBase {
if(acc.type == null || acc.type == this.type || acc.amount == 0) {
acc.type = this.type;
if(worldObj.rand.nextInt(5) == 0) {
acc.lastFlow = dir.getOpposite().ordinal();
if(worldObj.rand.nextInt(5) == 0 || this.amount == 1) { //force swap operations with single quanta to keep them moving
//1:4 chance that the fill states are simply swapped
//this promotes faster spreading and prevents spread limits
int buf = this.amount;
@ -90,6 +99,11 @@ public class TileEntityFoundryChannel extends TileEntityFoundryBase {
}
}
}
if(this.amount == 0) {
this.lastFlow = 0;
this.nextUpdate = 5;
}
}
super.updateEntity();
@ -99,4 +113,16 @@ public class TileEntityFoundryChannel extends TileEntityFoundryBase {
public int getCapacity() {
return MaterialShapes.INGOT.q(1);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.lastFlow = nbt.getByte("flow");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setByte("flow", (byte) this.lastFlow);
}
}

View File

@ -13,8 +13,9 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFoundryOutlet extends TileEntityFoundryBase {
public NTMMaterial filter = null;
public NTMMaterial lastFilter = null;
/** inverts redstone behavior, i.e. when TRUE, the outlet will be blocked by default and only open with redstone */
public boolean invertRedstone = false;
public boolean lastClosed = false;
@ -30,7 +31,8 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase {
if(worldObj.isRemote) {
boolean isClosed = isClosed();
if(this.lastClosed != isClosed) {
if(this.lastClosed != isClosed || this.filter != this.lastFilter) {
this.filter = lastFilter;
this.lastClosed = isClosed;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}

View File

@ -648,6 +648,7 @@ hbmmat.beryllium=Beryllium
hbmmat.bismuth=Bismut
hbmmat.borax=Borax
hbmmat.boron=Bor
hbmmat.carbon=Kohlenstoff
hbmmat.cinnabar=Zinnober
hbmmat.cmbsteel=Combinestahl
hbmmat.coal=Kohle

View File

@ -876,6 +876,7 @@ hbmmat.beryllium=Beryllium
hbmmat.bismuth=Bismuth
hbmmat.borax=Borax
hbmmat.boron=Boron
hbmmat.carbon=Carbon
hbmmat.cinnabar=Cinnabar
hbmmat.cmbsteel=Combine Steel
hbmmat.coal=Coal