recipe crap

This commit is contained in:
Boblet 2024-11-06 16:37:34 +01:00
parent 446f2f8c93
commit e64a21ffd3
8 changed files with 313 additions and 36 deletions

View File

@ -278,6 +278,10 @@ public class RecipesCommon {
public AStack copy() {
return new ComparableStack(item, stacksize, meta);
}
public ComparableStack copy(int stacksize) {
return new ComparableStack(item, stacksize, meta);
}
@Override
public boolean matchesRecipe(ItemStack stack, boolean ignoreSize) {
@ -390,6 +394,10 @@ public class RecipesCommon {
public AStack copy() {
return new OreDictStack(name, stacksize);
}
public OreDictStack copy(int stacksize) {
return new OreDictStack(name, stacksize);
}
@Override
public boolean matchesRecipe(ItemStack stack, boolean ignoreSize) {

View File

@ -119,24 +119,6 @@ public class GUIAnvil extends GuiContainer {
this.size = Math.max(0, (int)Math.ceil((this.recipes.size() - 10) / 2D));
}
/*@Override
protected void mouseMovedOrUp(int x, int y, int mode) {
super.mouseMovedOrUp(x, y, mode);
if(mode == -1) return; // we don't care about mouseMove
for(Object obj : this.inventorySlots.inventorySlots) {
Slot slot = (Slot) obj;
// if the mouse is over a slot, cancel
if(this.func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, x, y)) {
return;
}
}
if(mode == 0 && this.index > 0) this.index--;
if(mode == 1 && this.index < this.size) this.index++;
}*/
@Override
public void drawScreen(int x, int y, float interp) {
super.drawScreen(x, y, interp);

View File

@ -1,14 +1,28 @@
package com.hbm.inventory.gui;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.hbm.inventory.container.ContainerMachineAmmoPress;
import com.hbm.inventory.recipes.AmmoPressRecipes;
import com.hbm.inventory.recipes.AmmoPressRecipes.AmmoPressRecipe;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineAmmoPress;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.util.ResourceLocation;
public class GUIMachineAmmoPress extends GuiInfoContainer {
@ -16,24 +30,113 @@ public class GUIMachineAmmoPress extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_ammo_press.png");
private TileEntityMachineAmmoPress press;
private List<AmmoPressRecipe> recipes = new ArrayList();
int index;
int size;
int selection;
private GuiTextField search;
public GUIMachineAmmoPress(InventoryPlayer invPlayer, TileEntityMachineAmmoPress press) {
super(new ContainerMachineAmmoPress(invPlayer, press));
this.press = press;
this.xSize = 176;
this.ySize = 200;
regenerateRecipes();
}
@Override
public void initGui() {
super.initGui();
Keyboard.enableRepeatEvents(true);
this.search = new GuiTextField(this.fontRendererObj, guiLeft + 10, guiTop + 75, 66, 12);
this.search.setTextColor(-1);
this.search.setDisabledTextColour(-1);
this.search.setEnableBackgroundDrawing(false);
this.search.setMaxStringLength(25);
}
private void regenerateRecipes() {
this.recipes.clear();
this.recipes.addAll(AmmoPressRecipes.recipes);
resetPaging();
}
private void search(String search) {
search = search.toLowerCase(Locale.US);
this.recipes.clear();
if(search.isEmpty()) {
this.recipes.addAll(AmmoPressRecipes.recipes);
} else {
for(AmmoPressRecipe recipe : AmmoPressRecipes.recipes) {
if(recipe.output.getDisplayName().toLowerCase(Locale.US).contains(search)) {
this.recipes.add(recipe);
}
}
}
resetPaging();
}
private void resetPaging() {
this.index = 0;
this.selection = -1;
this.size = Math.max(0, (int)Math.ceil((this.recipes.size() - 12) / 2D));
}
@Override
public void drawScreen(int x, int y, float interp) {
super.drawScreen(x, y, interp);
for(Object obj : this.inventorySlots.inventorySlots) {
Slot slot = (Slot) obj;
// if the mouse is over a slot, cancel
if(this.func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, x, y) && slot.getHasStack()) {
return;
}
}
if(guiLeft <= x && guiLeft + xSize > x && guiTop < y && guiTop + ySize >= y && getSlotAtPosition(x, y) == null) {
if(!Mouse.isButtonDown(0) && !Mouse.isButtonDown(1) && Mouse.next()) {
int scroll = Mouse.getEventDWheel();
if(scroll > 0 && this.index > 0) this.index--;
if(scroll < 0 && this.index < this.size) this.index++;
}
}
}
@Override
protected void mouseClicked(int x, int y, int k) {
super.mouseClicked(x, y, k);
if(this.checkClick(x, y, 151, 17, 18, 18)) {
this.search.mouseClicked(x, y, k);
if(guiLeft + 7 <= x && guiLeft + 7 + 9 > x && guiTop + 17 < y && guiTop + 17 + 54 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
if(this.index > 0)
this.index--;
return;
}
if(guiLeft + 88 <= x && guiLeft + 88 + 9 > x && guiTop + 17 < y && guiTop + 17 + 54 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
if(this.index < this.size)
this.index++;
return;
}
}
@ -49,5 +152,65 @@ public class GUIMachineAmmoPress extends GuiInfoContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(guiLeft + 7 <= x && guiLeft + 7 + 9 > x && guiTop + 17 < y && guiTop + 17 + 54 >= y) {
drawTexturedModalRect(guiLeft + 7, guiTop + 17, 176, 0, 9, 54);
}
if(guiLeft + 88 <= x && guiLeft + 88 + 9 > x && guiTop + 17 < y && guiTop + 17 + 54 >= y) {
drawTexturedModalRect(guiLeft + 88, guiTop + 17, 185, 0, 9, 54);
}
if(this.search.isFocused()) {
drawTexturedModalRect(guiLeft + 8, guiTop + 72, 176, 54, 70, 16);
}
for(int i = index * 3; i < index * 3 + 12; i++) {
if(i >= recipes.size())
break;
int ind = i - index * 3;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
AmmoPressRecipe recipe = recipes.get(i);
FontRenderer font = null;
if (recipe.output != null) font = recipe.output.getItem().getFontRenderer(recipe.output);
if (font == null) font = fontRendererObj;
itemRender.zLevel = 100.0F;
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), recipe.output, guiLeft + 17 + 18 * (ind / 3), guiTop + 18 + 18 * (ind % 3));
itemRender.zLevel = 0.0F;
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_LIGHTING);
this.mc.getTextureManager().bindTexture(texture);
this.zLevel = 300.0F;
if(selection == i)
this.drawTexturedModalRect(guiLeft + 16 + 18 * (ind / 3), guiTop + 17 + 18 * (ind % 3), 194, 0, 18, 18);
else
this.drawTexturedModalRect(guiLeft + 16 + 18 * (ind / 3), guiTop + 17 + 18 * (ind % 3), 212, 0, 18, 18);
}
this.search.drawTextBox();
}
@Override
protected void keyTyped(char c, int key) {
if(this.search.textboxKeyTyped(c, key)) {
search(this.search.getText());
} else {
super.keyTyped(c, key);
}
}
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
}
}

View File

@ -4,20 +4,110 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.hbm.inventory.OreDictManager.*;
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.OreDictManager.DictFrame;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.RecipesCommon.OreDictStack;
import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.items.ItemEnums.EnumCasingType;
import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo;
import net.minecraft.item.ItemStack;
public class AmmoPressRecipes extends SerializableRecipe {
public List<AmmoPressRecipe> recipes = new ArrayList();
public static List<AmmoPressRecipe> recipes = new ArrayList();
@Override
public void registerDefaults() {
OreDictStack lead = new OreDictStack(PB.ingot());
OreDictStack steel = new OreDictStack(STEEL.ingot());
OreDictStack copper = new OreDictStack(CU.ingot());
OreDictStack plastic = new OreDictStack(ANY_PLASTIC.ingot());
OreDictStack smokeless = new OreDictStack(ANY_SMOKELESS.dust());
ComparableStack cSmall = new ComparableStack(ModItems.casing, 1, EnumCasingType.SMALL);
ComparableStack cBig = new ComparableStack(ModItems.casing, 1, EnumCasingType.LARGE);
ComparableStack sSmall = new ComparableStack(ModItems.casing, 1, EnumCasingType.SMALL_STEEL);
ComparableStack sBig = new ComparableStack(ModItems.casing, 1, EnumCasingType.LARGE_STEEL);
ComparableStack bpShell = new ComparableStack(ModItems.casing, 1, EnumCasingType.SHOTSHELL);
ComparableStack pShell = new ComparableStack(ModItems.casing, 1, EnumCasingType.BUCKSHOT);
ComparableStack sShell = new ComparableStack(ModItems.casing, 1, EnumCasingType.BUCKSHOT_ADVANCED);
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_SP, 8),
null, lead, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_FMJ, 8),
null, steel, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_SP, 8),
null, lead, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_FMJ, 8),
null, steel, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_SP, 8),
null, lead, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_FMJ, 8),
null, steel, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_SP, 8),
null, lead, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_FMJ, 8),
null, steel, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.P9_JHP, 8),
plastic, copper, null,
null, smokeless, null,
null, cSmall, null));
}
@Override
@ -25,6 +115,11 @@ public class AmmoPressRecipes extends SerializableRecipe {
return "hbmAmmoPress.json";
}
@Override
public String getComment() {
return "Input array describes slots from left to right, top to bottom. Make sure the input array is exactly 9 elements long, empty slots are represented by null.";
}
@Override
public Object getRecipeObject() {
return recipes;
@ -37,12 +132,40 @@ public class AmmoPressRecipes extends SerializableRecipe {
@Override
public void readRecipe(JsonElement recipe) {
JsonObject obj = (JsonObject) recipe;
ItemStack output = this.readItemStack(obj.get("output").getAsJsonArray());
JsonArray inputArray = obj.get("input").getAsJsonArray();
AStack[] input = new AStack[9];
for(int i = 0; i < 9; i++) {
JsonElement element = inputArray.get(i);
if(element.isJsonNull()) {
input[i] = null;
} else {
input[i] = this.readAStack(element.getAsJsonArray());
}
}
this.recipes.add(new AmmoPressRecipe(output, input));
}
@Override
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
AmmoPressRecipe rec = (AmmoPressRecipe) recipe;
writer.name("output");
this.writeItemStack(rec.output, writer);
writer.name("input").beginArray();
for(int i = 0; i < rec.input.length; i++) {
if(rec.input[i] == null) {
writer.nullValue();
} else {
this.writeAStack(rec.input[i], writer);
}
}
writer.endArray();
}
public static class AmmoPressRecipe {

View File

@ -73,6 +73,7 @@ public abstract class SerializableRecipe {
recipeHandlers.add(new ArcWelderRecipes());
recipeHandlers.add(new RotaryFurnaceRecipes());
recipeHandlers.add(new ExposureChamberRecipes());
recipeHandlers.add(new AmmoPressRecipes());
recipeHandlers.add(new AssemblerRecipes());
recipeHandlers.add(new MatDistribution());

View File

@ -201,7 +201,7 @@ public class BulletConfig implements Cloneable {
float newHealth = living.getHealth();
if(bullet.config.damageFalloffByPen) bullet.damage -= Math.max(prevHealth - newHealth, 0);
if(bullet.config.damageFalloffByPen) bullet.damage -= Math.max(prevHealth - newHealth, 0) * 0.5;
if(!bullet.doesPenetrate() || bullet.damage < 0) {
bullet.setPosition(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
bullet.setDead();

View File

@ -1598,13 +1598,13 @@ item.casing_44.name=.44 Magnum-Hülsen
item.casing_50.name=Großkaliberhülsen
item.casing_9.name=Kleinkaliberhülsen
item.casing_buckshot.name=Schrothülsen
item.casing.small.name=Kleine Rotgussgehäuse
item.casing.small_steel.name=Stahlhülsen für kleine Waffen
item.casing.large.name=Large Rotgussgehäuse
item.casing.large_steel.name=Große Waffenstahlhülsen
item.casing.shotshell.name=Schrotpatronenhülsen
item.casing.buckshot.name=Schrothülsen
item.casing.buckshot_advanced.name=Fortschrittliche Schrothülsen
item.casing.small.name=Kleine Patronenhülse
item.casing.small_steel.name=Kleine Waffenstahlhülse
item.casing.large.name=Große Patronenhülse
item.casing.large_steel.name=Große Waffenstahlhülse
item.casing.shotshell.name=Schwarzpulver-Schrothülse
item.casing.buckshot.name=Plastik-Schrothülse
item.casing.buckshot_advanced.name=Fortgeschrittene Schrothülse
item.catalyst_clay.name=Tonerde-Katalysator
item.catalytic_converter.name=Katalytischer Konverter
item.cbt_device.name=CBT-Gerät

View File

@ -2367,14 +2367,14 @@ item.casing_357.name=.357 Magnum Casings
item.casing_44.name=.44 Magnum Casings
item.casing_50.name=Large Caliber Casings
item.casing_9.name=Small Caliber Casings
item.casing_buckshot.name=Buckshot Casings
item.casing.small.name=Small Gunmetal Casings
item.casing.small_steel.name=Small Weapon Steel Casings
item.casing.large.name=Large Gunmetal Casings
item.casing.large_steel.name=Large Weapon Steel Casings
item.casing.shotshell.name=Shotshell Casings
item.casing.buckshot.name=Buckshot Casings
item.casing.buckshot_advanced.name=Advanced Buckshot Casings
item.casing_buckshot.name=Buckshot Casing
item.casing.small.name=Small Gunmetal Casing
item.casing.small_steel.name=Small Weapon Steel Casing
item.casing.large.name=Large Gunmetal Casing
item.casing.large_steel.name=Large Weapon Steel Casing
item.casing.shotshell.name=Black Powder Shotshell Casing
item.casing.buckshot.name=Plastic Shotshell Casing
item.casing.buckshot_advanced.name=Advanced Shotshell Casing
item.catalyst_clay.name=Clay Catalyst
item.catalytic_converter.name=Catalytic Converter
item.cbt_device.name=CBT Device