Merge branch 'HbmMods:master' into Optimization

This commit is contained in:
BallOfEnergy 2024-11-05 14:12:38 -06:00 committed by GitHub
commit 6516ff7aa2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 186 additions and 13 deletions

View File

@ -0,0 +1,71 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotCraftingOutput;
import com.hbm.tileentity.machine.TileEntityMachineAmmoPress;
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 ContainerMachineAmmoPress extends Container {
private TileEntityMachineAmmoPress press;
public ContainerMachineAmmoPress(InventoryPlayer playerInv, TileEntityMachineAmmoPress tile) {
press = tile;
//Inputs
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
this.addSlotToContainer(new Slot(tile, i * 3 + j, 116 + j * 18, 18 + i * 18));
}
}
//Output
this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 9, 134, 72));
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, 118 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 176));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack rStack = null;
Slot slot = (Slot) this.inventorySlots.get(index);
if(slot != null && slot.getHasStack()) {
ItemStack stack = slot.getStack();
rStack = stack.copy();
if(index <= 9) {
if(!this.mergeItemStack(stack, 10, this.inventorySlots.size(), true)) {
return null;
}
} else {
if(!this.mergeItemStack(stack, 0, 9, false)) {
return null;
}
}
if(stack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
}
return rStack;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return press.isUseableByPlayer(player);
}
}

View File

@ -0,0 +1,53 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerMachineAmmoPress;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineAmmoPress;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIMachineAmmoPress extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_ammo_press.png");
private TileEntityMachineAmmoPress press;
public GUIMachineAmmoPress(InventoryPlayer invPlayer, TileEntityMachineAmmoPress press) {
super(new ContainerMachineAmmoPress(invPlayer, press));
this.press = press;
this.xSize = 176;
this.ySize = 200;
}
@Override
public void drawScreen(int x, int y, float interp) {
super.drawScreen(x, y, interp);
}
@Override
protected void mouseClicked(int x, int y, int k) {
super.mouseClicked(x, y, k);
if(this.checkClick(x, y, 151, 17, 18, 18)) {
}
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.press.hasCustomInventoryName() ? this.press.getInventoryName() : I18n.format(this.press.getInventoryName());
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 0xffffff);
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);
}
}

View File

@ -0,0 +1,57 @@
package com.hbm.inventory.recipes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonElement;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.recipes.loader.SerializableRecipe;
import net.minecraft.item.ItemStack;
public class AmmoPressRecipes extends SerializableRecipe {
public List<AmmoPressRecipe> recipes = new ArrayList();
@Override
public void registerDefaults() {
}
@Override
public String getFileName() {
return "hbmAmmoPress.json";
}
@Override
public Object getRecipeObject() {
return recipes;
}
@Override
public void deleteRecipes() {
recipes.clear();
}
@Override
public void readRecipe(JsonElement recipe) {
}
@Override
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
}
public static class AmmoPressRecipe {
public ItemStack output;
public AStack[] input;
public AmmoPressRecipe(ItemStack output, AStack... input) {
this.output = output;
this.input = input;
}
}
}

View File

@ -13,7 +13,6 @@ import com.hbm.items.weapon.sedna.ItemGunBaseNT.GunState;
import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext;
import com.hbm.items.weapon.sedna.ItemGunBaseNT.WeaponQuality;
import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo;
import com.hbm.items.weapon.sedna.mags.IMagazine;
import com.hbm.items.weapon.sedna.mags.MagazineFullReload;
import com.hbm.main.MainRegistry;
import com.hbm.particle.SpentCasing;

View File

@ -8,8 +8,6 @@ import com.hbm.render.anim.HbmAnimations;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
public class ItemRenderSTG77 extends ItemRenderWeaponBase {

View File

@ -101,6 +101,7 @@ public class TileMappings {
put(TileEntityCrateDesh.class, "tileentity_crate_desh");
put(TileEntityMassStorage.class, "tileentity_mass_storage");
put(TileEntityMachinePress.class, "tileentity_press");
put(TileEntityMachineAmmoPress.class, "tileentity_ammo_press");
put(TileEntityMachineSiren.class, "tileentity_siren");
put(TileEntityMachineSPP.class, "tileentity_spp");
put(TileEntityMachineRadGen.class, "tileentity_radgen");

View File

@ -1,5 +1,7 @@
package com.hbm.tileentity.machine;
import com.hbm.inventory.container.ContainerMachineAmmoPress;
import com.hbm.inventory.gui.GUIMachineAmmoPress;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
@ -25,14 +27,6 @@ public class TileEntityMachineAmmoPress extends TileEntityMachineBase implements
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@Override
@SideOnly(Side.CLIENT)
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerMachineAmmoPress(player.inventory, this); }
@Override @SideOnly(Side.CLIENT) public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIMachineAmmoPress(player.inventory, this); }
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB