evil mechanism

This commit is contained in:
Boblet 2025-11-27 10:51:48 +01:00
parent 4322892abb
commit 3bdd7b4c94
12 changed files with 138 additions and 62 deletions

View File

@ -110,12 +110,12 @@ public abstract class NEIGenericRecipeHandler extends TemplateRecipeHandler impl
}
@Override public List<PositionedStack> getIngredients() { return getCycledIngredients(cycleticks / 20, Arrays.asList(this.input)); }
@Override public PositionedStack getResult() { return this.output[0]; }
@Override public PositionedStack getResult() { return null; }
@Override
public List<PositionedStack> getOtherStacks() {
List<PositionedStack> other = new ArrayList();
for(int i = 1; i < this.output.length; i++) other.add(this.output[i]);
for(int i = 0; i < this.output.length; i++) other.add(this.output[i]);
other.add(this.machine);
if(this.template != null) other.add(this.template);
return getCycledIngredients(cycleticks / 20, other);

View File

@ -0,0 +1,13 @@
package com.hbm.handler.nei;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.recipes.PrecAssRecipes;
public class PrecAssRecipeHandler extends NEIGenericRecipeHandler {
public PrecAssRecipeHandler() {
super(ModBlocks.machine_precass.getLocalizedName(), PrecAssRecipes.INSTANCE, ModBlocks.machine_precass);
}
@Override public String getRecipeID() { return "ntmPrecAss"; }
}

View File

@ -30,7 +30,7 @@ public class PrecAssRecipes extends GenericRecipes<GenericRecipe> {
@Override
public void registerDefaults() {
registerPair(new GenericRecipe("precass.controller").setup(400, 15_000L)
.inputItems(new ComparableStack(ModItems.circuit, 32, EnumCircuitType.CHIP),
new ComparableStack(ModItems.circuit, 32, EnumCircuitType.CAPACITOR),
@ -42,6 +42,7 @@ public class PrecAssRecipes extends GenericRecipes<GenericRecipe> {
DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CONTROLLER), 10, 25);
}
/** Registers a generic pair of faulty product and recycling of broken items. */
public void registerPair(GenericRecipe recipe, ItemStack output, int chance, int reclaim) {
recipe.outputItems(new ChanceOutputMulti(
new ChanceOutput(output, chance),
@ -56,6 +57,7 @@ public class PrecAssRecipes extends GenericRecipes<GenericRecipe> {
for(int i = 0; i < recycle.length; i++) {
ItemStack stack = recipe.inputItem[i].extractForNEI().get(0).copy();
int stackSize = (int) (recipe.inputItem[i].stacksize * fReclaim);
// if the resulting stack size is >= 1, use that, otherwise use the original stack size but a chance output percentage
if(stackSize > 0) {
stack.stackSize = stackSize;
recycle[i] = new ChanceOutput(stack);

View File

@ -12,6 +12,7 @@ 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.util.ItemStackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
@ -38,6 +39,8 @@ public abstract class GenericRecipes<T extends GenericRecipe> extends Serializab
public static final String POOL_PREFIX_DISCOVER = "discover.";
/** Secret recipes, self-explantory. Why even have this comment? */
public static final String POOL_PREFIX_SECRET = "secret.";
/** 528 greyprints */
public static final String POOL_PREFIX_528 = "528.";
public List<T> recipeOrderedList = new ArrayList();
public HashMap<String, T> recipeNameMap = new HashMap();
@ -235,13 +238,14 @@ public abstract class GenericRecipes<T extends GenericRecipe> extends Serializab
@Override
public ItemStack collapse() {
if(this.chance >= 1F) return getSingle().copy();
return RNG.nextFloat() <= chance ? getSingle().copy() : null;
if(this.chance >= 1F) return getSingle();
return RNG.nextFloat() <= chance ? getSingle() : null;
}
@Override public ItemStack getSingle() { return this.stack; }
@Override public ItemStack getSingle() { return this.stack.copy(); }
@Override public boolean possibleMultiOutput() { return false; }
@Override public ItemStack[] getAllPossibilities() { return new ItemStack[] {getSingle()}; }
/** For NEI, includes tooltip labels */
@Override public ItemStack[] getAllPossibilities() { return new ItemStack[] {this.chance >= 1F ? getSingle() : ItemStackUtil.addTooltipToStack(getSingle(), EnumChatFormatting.RED + "" + (int)(this.chance * 1000) / 10F + "%")}; }
@Override
public void serialize(JsonWriter writer) throws IOException {
@ -297,7 +301,13 @@ public abstract class GenericRecipes<T extends GenericRecipe> extends Serializab
@Override public ItemStack[] getAllPossibilities() {
ItemStack[] outputs = new ItemStack[pool.size()];
for(int i = 0; i < outputs.length; i++) outputs[i] = pool.get(i).getAllPossibilities()[0];
int totalWeight = WeightedRandom.getTotalWeight(pool);
for(int i = 0; i < outputs.length; i++) {
ChanceOutput out = pool.get(i);
float chance = (float) out.itemWeight / (float) totalWeight;
outputs[i] = chance >= 1 ? out.getAllPossibilities()[0] :
ItemStackUtil.addTooltipToStack(out.getAllPossibilities()[0], EnumChatFormatting.RED + "" + (int)(chance * 1000) / 10F + "%");
}
return outputs;
}

View File

@ -24,6 +24,7 @@ public class ItemBlueprints extends Item {
@SideOnly(Side.CLIENT) protected IIcon iconDiscover;
@SideOnly(Side.CLIENT) protected IIcon iconSecret;
@SideOnly(Side.CLIENT) protected IIcon icon528;
@Override
@SideOnly(Side.CLIENT)
@ -31,6 +32,7 @@ public class ItemBlueprints extends Item {
super.registerIcons(reg);
this.iconDiscover = reg.registerIcon(this.getIconString() + "_discover");
this.iconSecret = reg.registerIcon(this.getIconString() + "_secret");
this.icon528 = reg.registerIcon(this.getIconString() + "_528");
}
@Override
@ -45,11 +47,12 @@ public class ItemBlueprints extends Item {
if(stack.hasTagCompound()) {
String poolName = stack.stackTagCompound.getString("pool");
if(poolName == null) return this.itemIcon;
if(poolName.startsWith(GenericRecipes.POOL_PREFIX_DISCOVER)) return this.iconDiscover;
if(poolName.startsWith(GenericRecipes.POOL_PREFIX_SECRET)) return this.iconSecret;
if(poolName.startsWith(GenericRecipes.POOL_PREFIX_DISCOVER)) return this.iconDiscover; // beige
if(poolName.startsWith(GenericRecipes.POOL_PREFIX_SECRET)) return this.iconSecret; // black
if(poolName.startsWith(GenericRecipes.POOL_PREFIX_528)) return this.icon528; // grey
}
return this.itemIcon;
return this.itemIcon; // blue
}
@Override

View File

@ -17,21 +17,25 @@ public class NEIRegistry {
handlers.add(new AnvilRecipeHandler());
handlers.add(new SmithingRecipeHandler());
handlers.add(new PressRecipeHandler());
handlers.add(new AlloyFurnaceRecipeHandler());
handlers.add(new ShredderRecipeHandler());
handlers.add(new PressRecipeHandler());
handlers.add(new CrucibleSmeltingHandler());
handlers.add(new CrucibleAlloyingHandler());
handlers.add(new CrucibleCastingHandler());
handlers.add(new AssemblyMachineRecipeHandler());
handlers.add(new PrecAssRecipeHandler());
handlers.add(new ChemicalPlantRecipeHandler());
handlers.add(new RefineryRecipeHandler());
handlers.add(new CentrifugeRecipeHandler());
handlers.add(new GasCentrifugeRecipeHandler());
handlers.add(new BreederRecipeHandler());
handlers.add(new CyclotronRecipeHandler());
handlers.add(new AssemblyMachineRecipeHandler());
handlers.add(new RefineryRecipeHandler());
handlers.add(new VacuumRecipeHandler());
handlers.add(new CrackingHandler());
handlers.add(new RadiolysisRecipeHandler());
handlers.add(new ReformingHandler());
handlers.add(new HydrotreatingHandler());
handlers.add(new ChemicalPlantRecipeHandler());
handlers.add(new PUREXRecipeHandler());
handlers.add(new OreSlopperHandler()); //before acidizing
handlers.add(new CrystallizerRecipeHandler());
@ -41,9 +45,6 @@ public class NEIRegistry {
handlers.add(new FuelPoolHandler());
handlers.add(new RBMKRodDisassemblyHandler());
handlers.add(new RBMKWasteDecayHandler());
handlers.add(new CrucibleSmeltingHandler());
handlers.add(new CrucibleAlloyingHandler());
handlers.add(new CrucibleCastingHandler());
handlers.add(new ToolingHandler());
handlers.add(new ConstructionHandler());
handlers.add(new SatelliteHandler());

View File

@ -57,11 +57,6 @@ public class RenderPrecAss extends TileEntitySpecialRenderer implements IItemRen
BobMathUtil.interp(assembler.prevArmAngles[1], assembler.armAngles[1], interp),
BobMathUtil.interp(assembler.prevArmAngles[2], assembler.armAngles[2], interp)
};
// test for null position
arm[0] = 45;
arm[1] = -30;
arm[2] = 45;
GL11.glRotated(spin, 0, 1, 0);
ResourceManager.assembly_machine.renderPart("Ring");
@ -69,7 +64,7 @@ public class RenderPrecAss extends TileEntitySpecialRenderer implements IItemRen
for(int i = 0; i < 4; i++) {
renderArm(arm, BobMathUtil.interp(assembler.prevStrikers[i], assembler.strikers[i], interp));
GL11.glRotated(90, 0, 1, 0);
GL11.glRotated(-90, 0, 1, 0);
}
GL11.glPopMatrix();
@ -156,9 +151,9 @@ public class RenderPrecAss extends TileEntitySpecialRenderer implements IItemRen
ResourceManager.assembly_machine.renderPart("Frame");
ResourceManager.assembly_machine.renderPart("Ring");
ResourceManager.assembly_machine.renderPart("Ring2");
double[] arm = new double[] {45, -15, -5};
double[] arm = new double[] {45, -30, 45};
for(int i = 0; i < 4; i++) {
renderArm(arm, -0.75);
renderArm(arm, 0);
GL11.glRotated(90, 0, 1, 0);
}
GL11.glShadeModel(GL11.GL_FLAT);

View File

@ -169,18 +169,11 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl
if(this.ringTarget > this.ring) this.ring += this.ringSpeed;
if(this.ringTarget < this.ring) this.ring -= this.ringSpeed;
if(this.ringTarget == this.ring) {
if(ringTarget >= 360) {
this.ringTarget -= 360D;
this.ring -= 360D;
this.prevRing -= 360D;
}
if(ringTarget <= -360) {
this.ringTarget += 360D;
this.ring += 360D;
this.prevRing += 360D;
}
double sub = ringTarget >= 360 ? -360D : 360D;
this.ringTarget += sub;
this.ring += sub;
this.prevRing += sub;
this.ringDelay = 20 + worldObj.rand.nextInt(21);
//MainRegistry.proxy.playSoundClient(xCoord, yCoord, zCoord, "hbm:block.assemblerStop", this.getVolume(0.25F), 1.5F);
}
} else {
if(this.ringDelay > 0) this.ringDelay--;

View File

@ -37,6 +37,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
// horribly copy-pasted crap device
@ -64,6 +65,7 @@ public class TileEntityMachinePrecAss extends TileEntityMachineBase implements I
public double[] prevArmAngles = new double[] {45, -15, -5};
public double[] strikers = new double[4];
public double[] prevStrikers = new double[4];
public boolean[] strikerDir = new boolean[4];
protected int strikerIndex;
protected int strikerDelay;
@ -151,37 +153,94 @@ public class TileEntityMachinePrecAss extends TileEntityMachineBase implements I
this.prevRing = this.ring;
if(didProcess) {
if(this.ring != this.ringTarget) {
double ringDelta = Math.abs(this.ringTarget - this.ring);
if(ringDelta <= this.ringSpeed) this.ring = this.ringTarget;
if(this.ringTarget > this.ring) this.ring += this.ringSpeed;
if(this.ringTarget < this.ring) this.ring -= this.ringSpeed;
if(this.ringTarget == this.ring) {
if(ringTarget >= 360) {
this.ringTarget -= 360D;
this.ring -= 360D;
this.prevRing -= 360D;
}
if(ringTarget <= -360) {
this.ringTarget += 360D;
this.ring += 360D;
this.prevRing += 360D;
}
this.ringDelay = 20 + worldObj.rand.nextInt(21);
}
for(int i = 0; i < 4; i++) {
if(this.strikerDir[i]) {
this.strikers[i] = -0.75D;
this.strikerDir[i] = false;
} else {
this.strikers[i] = MathHelper.clamp_double(this.strikers[i] + 0.5D, -0.75D, 0D);
}
}
if(this.isInWorkingPosition(prevArmAngles) && !this.isInWorkingPosition(armAngles)) {
if(!this.muffled) MainRegistry.proxy.playSoundClient(xCoord, yCoord, zCoord, "hbm:block.assemblerStop", this.getVolume(0.25F), 1.25F + worldObj.rand.nextFloat() * 0.25F);
}
if(this.ring != this.ringTarget) {
double ringDelta = Math.abs(this.ringTarget - this.ring);
if(ringDelta <= this.ringSpeed) this.ring = this.ringTarget;
if(this.ringTarget > this.ring) this.ring += this.ringSpeed;
if(this.ringTarget < this.ring) this.ring -= this.ringSpeed;
if(this.ringTarget == this.ring) {
double sub = ringTarget >= 360 ? -360D : 360D;
this.ringTarget += sub;
this.ring += sub;
this.prevRing += sub;
this.ringDelay = 100 + worldObj.rand.nextInt(21);
}
}
if(didProcess) {
if(this.ring == this.ringTarget) {
if(this.ringDelay > 0) this.ringDelay--;
if(this.ringDelay <= 0) {
this.ringTarget += (worldObj.rand.nextDouble() * 2 - 1) * 135;
this.ringTarget += 45 * (worldObj.rand.nextBoolean() ? -1 : 1);
this.ringSpeed = 10D + worldObj.rand.nextDouble() * 5D;
if(!this.muffled) MainRegistry.proxy.playSoundClient(xCoord, yCoord, zCoord, "hbm:block.assemblerStart", this.getVolume(0.25F), 1.25F + worldObj.rand.nextFloat() * 0.25F);
}
}
if(!isInWorkingPosition(this.armAngles) && canArmsMove()) {
move(WORKING_POSITION);
}
if(isInWorkingPosition(this.armAngles)) {
this.strikerDelay--;
if(this.strikerDelay <= 0) {
this.strikerDir[this.strikerIndex] = true;
this.strikerIndex = (this.strikerIndex + 1) % this.strikers.length;
this.strikerDelay = this.strikerIndex == 3 ? 10 : 2;
}
}
} else {
for(int i = 0; i < 4; i++) this.strikerDir[i] = false; // set all strikers to retract
if(canArmsMove()) move(NULL_POSITION);
}
}
}
public double[] NULL_POSITION = new double[] {45, -30, 45};
public double[] WORKING_POSITION = new double[] {45, -15, -5};
private boolean canArmsMove() {
for(int i = 0; i < 4; i++) if(this.strikers[i] != 0) return false;
return true;
}
private boolean isInWorkingPosition(double[] arms) {
for(int i = 0; i < 3; i++) if(arms[i] != WORKING_POSITION[i]) return false;
return true;
}
private boolean move(double[] targetAngles) {
boolean didMove = false;
for(int i = 0; i < armAngles.length; i++) {
if(armAngles[i] == targetAngles[i]) continue;
didMove = true;
double angle = armAngles[i];
double target = targetAngles[i];
double turn = 15D;
double delta = Math.abs(angle - target);
if(delta <= turn) { armAngles[i] = targetAngles[i]; continue; }
if(angle < target) armAngles[i] += turn;
else armAngles[i] -= turn;
}
return !didMove;
}
@Override public AudioWrapper createAudioLoop() {
return MainRegistry.proxy.getLoopedSound("hbm:block.motor", xCoord, yCoord, zCoord, 0.5F, 15F, 0.75F, 20);
}
@ -233,10 +292,6 @@ public class TileEntityMachinePrecAss extends TileEntityMachineBase implements I
this.maxPower = buf.readLong();
this.didProcess = buf.readBoolean();
this.assemblerModule.deserialize(buf);
if(wasProcessing && !didProcess) {
MainRegistry.proxy.playSoundClient(xCoord, yCoord, zCoord, "hbm:block.assemblerStop", this.getVolume(0.25F), 1.5F);
}
}
@Override
@ -324,7 +379,7 @@ public class TileEntityMachinePrecAss extends TileEntityMachineBase implements I
@Override
public void provideInfo(UpgradeType type, int level, List<String> info, boolean extendedInfo) {
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_assembly_machine));
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_precass));
if(type == UpgradeType.SPEED) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(KEY_SPEED, "+" + (level * 100 / 3) + "%"));
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(KEY_CONSUMPTION, "+" + (level * 50) + "%"));

View File

@ -411,6 +411,7 @@ container.machineLargeTurbine=Industrielle Dampfturbine
container.machineLiquefactor=Verflüssiger
container.machineMixer=Industrieller Mixer
container.machineOreSlopper=B.E.M.
container.machinePrecAss=Präzisions-Montagemaschine
container.machinePUREX=PUREX
container.machinePyroOven=Pyrolyseofen
container.machineRefinery=Ölraffinerie
@ -4539,6 +4540,7 @@ tile.machine_nuke_furnace_on.name=Atombetriebener Ofen
tile.machine_orbus.name=Schwerer Magnetischer Lagerbehälter
tile.machine_ore_slopper.name=Bedrockerzmaschine
tile.machine_powerrtg.name=PT-Isotopenzelle
tile.machine_precass.name=Präzisions-Montagemaschine
tile.machine_press.name=Befeuerte Presse
tile.machine_puf6_tank.name=Plutoniumhexafluorid-Tank
tile.machine_pumpjack.name=Pferdekopfpumpe

View File

@ -816,6 +816,7 @@ container.machineLargeTurbine=Industrial Steam Turbine
container.machineLiquefactor=Liquefactor
container.machineMixer=Industrial Mixer
container.machineOreSlopper=B.O.P.
container.machinePrecAss=Precision Assembly Machine
container.machinePUREX=PUREX
container.machinePyroOven=Pyrolysis Oven
container.machineRefinery=Oil Refinery
@ -5806,6 +5807,7 @@ tile.machine_nuke_furnace_on.name=Nuclear Furnace
tile.machine_orbus.name=Heavy Magnetic Storage Tank
tile.machine_ore_slopper.name=Bedrock Ore Processor
tile.machine_powerrtg.name=PT Isotope Cell
tile.machine_precass.name=Precision Assembly Machine
tile.machine_press.name=Burner Press
tile.machine_puf6_tank.name=Plutonium Hexafluoride Tank
tile.machine_pumpjack.name=Pumpjack

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B