Automatic Hell

https: //github.com/SpitefulFox/Avaritia/commit/a4033ac57105fb673ef688aa71a23e015589e23b
Co-Authored-By: SpitefulFox <[email protected]>
This commit is contained in:
glowredmanandSpitefulFox committed 2022-02-05 01:20:23 +01:00
1 parent 7cefe28ba1
commit 94f43164cc
6 files changed
+364 -5

No files matched your search

@@ -3,6 +3,7 @@ package fox.spiteful.avaritia.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fox.spiteful.avaritia.Avaritia;
import fox.spiteful.avaritia.tile.TileEntityAutoDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
@@ -61,7 +62,7 @@ public class BlockAutoDireCrafting extends BlockContainer {
}
else
{
player.openGui(Avaritia.instance, 1, world, x, y, z);
player.openGui(Avaritia.instance, 4, world, x, y, z);
return true;
}
}
@@ -69,12 +70,12 @@ public class BlockAutoDireCrafting extends BlockContainer {
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityDireCrafting();
return new TileEntityAutoDireCrafting();
}
public void breakBlock(World world, int x, int y, int z, Block block, int wut)
{
TileEntityDireCrafting craft = (TileEntityDireCrafting)world.getTileEntity(x, y, z);
TileEntityAutoDireCrafting craft = (TileEntityAutoDireCrafting)world.getTileEntity(x, y, z);
if (craft != null)
{
@@ -420,9 +420,9 @@ public class Compat {
" NNNNN ",
" NNNINNN ",
"NNNIIINNN",
"NNNIEINNN",
"NNIIEIINN",
"NNNIIINNN",
" NNNNNNN ",
" NNNINNN ",
" NNNNN ",
'N', new ItemStack(LudicrousItems.resource, 1, 4),
'E', new ItemStack(Items.egg),
@@ -0,0 +1,144 @@
package fox.spiteful.avaritia.gui;
import fox.spiteful.avaritia.blocks.LudicrousBlocks;
import fox.spiteful.avaritia.crafting.ExtremeCraftingManager;
import fox.spiteful.avaritia.tile.TileEntityAutoDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import fox.spiteful.avaritia.tile.inventory.InventoryDireCraftResult;
import fox.spiteful.avaritia.tile.inventory.InventoryDireCrafting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ContainerAutoExtremeCrafting extends Container {
/** The crafting matrix inventory (9x9). */
public InventoryCrafting craftMatrix;
public IInventory craftResult;
private World worldObj;
private int posX;
private int posY;
private int posZ;
public ContainerAutoExtremeCrafting(InventoryPlayer player, World world, int x, int y, int z, TileEntityAutoDireCrafting table)
{
this.worldObj = world;
this.posX = x;
this.posY = y;
this.posZ = z;
//craftMatrix = new InventoryDireCrafting(this, table);
//craftResult = new InventoryDireCraftResult(table);
this.addSlotToContainer(new SlotCrafting(player.player, this.craftMatrix, this.craftResult, 0, 210, 80));
int wy;
int ex;
for (wy = 0; wy < 9; ++wy)
{
for (ex = 0; ex < 9; ++ex)
{
this.addSlotToContainer(new Slot(this.craftMatrix, ex + wy * 9, 12 + ex * 18, 8 + wy * 18));
}
}
for (wy = 0; wy < 3; ++wy)
{
for (ex = 0; ex < 9; ++ex)
{
this.addSlotToContainer(new Slot(player, ex + wy * 9 + 9, 39 + ex * 18, 174 + wy * 18));
}
}
for (ex = 0; ex < 9; ++ex)
{
this.addSlotToContainer(new Slot(player, ex, 39 + ex * 18, 232));
}
this.onCraftMatrixChanged(this.craftMatrix);
}
/**
* Callback for when the crafting matrix is changed.
*/
public void onCraftMatrixChanged(IInventory matrix)
{
this.craftResult.setInventorySlotContents(0, ExtremeCraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
}
/**
* Called when the container is closed.
*/
public void onContainerClosed(EntityPlayer player)
{
super.onContainerClosed(player);
}
public boolean canInteractWith(EntityPlayer player)
{
return this.worldObj.getBlock(this.posX, this.posY, this.posZ) == LudicrousBlocks.dire_crafting && player.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
}
/**
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
*/
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(slotNumber);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (slotNumber == 0)
{
if (!this.mergeItemStack(itemstack1, 82, 118, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (slotNumber >= 82 && slotNumber < 109)
{
if (!this.mergeItemStack(itemstack1, 109, 118, false))
{
return null;
}
}
else if (slotNumber >= 109 && slotNumber < 118)
{
if (!this.mergeItemStack(itemstack1, 82, 109, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 82, 118, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(player, itemstack1);
}
return itemstack;
}
}
@@ -0,0 +1,38 @@
package fox.spiteful.avaritia.gui;
import fox.spiteful.avaritia.tile.TileEntityAutoDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class GUIAutoExtremeCrafting extends GuiContainer {
private static final ResourceLocation tex = new ResourceLocation("avaritia:textures/gui/dire_crafting_gui.png");
public GUIAutoExtremeCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int x, int y, int z, TileEntityAutoDireCrafting table)
{
super(new ContainerAutoExtremeCrafting(par1InventoryPlayer, par2World, x, y, z, table));
this.ySize = 256;
this.xSize = 238;
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j)
{
//this.fontRendererObj.drawString(StatCollector.translateToLocal("container.extreme_crafting"), 28, 6, 4210752);
//this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(tex);
int foo = (this.width - this.xSize) / 2;
int bar = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(foo, bar, 0, 0, this.ySize, this.ySize);
}
}
@@ -1,6 +1,7 @@
package fox.spiteful.avaritia.gui;
import cpw.mods.fml.common.network.IGuiHandler;
import fox.spiteful.avaritia.tile.TileEntityAutoDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityCompressor;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityNeutron;
@@ -20,6 +21,8 @@ public class GooeyHandler implements IGuiHandler {
return new GUINeutron(player.inventory, (TileEntityNeutron)world.getTileEntity(x, y, z));
else if(ID == 3)
return new GUICompressor(player.inventory, (TileEntityCompressor)world.getTileEntity(x, y, z));
else if(ID == 4)
return new GUIAutoExtremeCrafting(player.inventory, world, x, y, z, (TileEntityAutoDireCrafting)world.getTileEntity(x, y, z));
return null;
}
@@ -33,6 +36,8 @@ public class GooeyHandler implements IGuiHandler {
return new ContainerNeutron(player.inventory, (TileEntityNeutron)world.getTileEntity(x, y, z));
else if(ID == 3)
return new ContainerCompressor(player.inventory, (TileEntityCompressor)world.getTileEntity(x, y, z));
else if(ID == 4)
return new ContainerAutoExtremeCrafting(player.inventory, world, x, y, z, (TileEntityAutoDireCrafting)world.getTileEntity(x, y, z));
return null;
}
}
@@ -0,0 +1,171 @@
package fox.spiteful.avaritia.tile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class TileEntityAutoDireCrafting extends TileLudicrous implements IInventory, ISidedInventory{
private ItemStack result;
private ItemStack[] matrix = new ItemStack[81];
@Override
public boolean canUpdate()
{
return false;
}
@Override
public void readCustomNBT(NBTTagCompound tag)
{
this.result = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Result"));
for(int x = 0;x < matrix.length;x++){
matrix[x] = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Craft" + x));
}
}
@Override
public void writeCustomNBT(NBTTagCompound tag)
{
if(result != null) {
NBTTagCompound produce = new NBTTagCompound();
result.writeToNBT(produce);
tag.setTag("Result", produce);
}
else
tag.removeTag("Result");
for(int x = 0;x < matrix.length;x++){
if(matrix[x] != null){
NBTTagCompound craft = new NBTTagCompound();
matrix[x].writeToNBT(craft);
tag.setTag("Craft" + x, craft);
}
else
tag.removeTag("Craft" + x);
}
}
@Override
public int getSizeInventory()
{
return 82;
}
@Override
public ItemStack getStackInSlot(int slot){
if(slot == 0)
return result;
else if(slot <= matrix.length)
return matrix[slot - 1];
else
return null;
}
@Override
public ItemStack decrStackSize(int slot, int decrement){
if(slot == 0){
if(result != null){
for(int x = 1;x <= matrix.length;x++){
decrStackSize(x, 1);
}
if(result.stackSize <= decrement) {
ItemStack craft = result;
result = null;
return craft;
}
ItemStack split = result.splitStack(decrement);
if(result.stackSize <= 0)
result = null;
return split;
}
else
return null;
}
else if(slot <= matrix.length){
if(matrix[slot - 1] != null){
if(matrix[slot - 1].stackSize <= decrement){
ItemStack ingredient = matrix[slot - 1];
matrix[slot - 1] = null;
return ingredient;
}
ItemStack split = matrix[slot - 1].splitStack(decrement);
if(matrix[slot - 1].stackSize <= 0)
matrix[slot - 1] = null;
return split;
}
}
return null;
}
@Override
public void openInventory() {}
@Override
public void closeInventory() {}
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack){
return false;
}
@Override
public int getInventoryStackLimit(){
return 64;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack){
if(slot == 0){
result = stack;
}
else if(slot <= matrix.length){
matrix[slot - 1] = stack;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot){
return null;
}
/**
* Returns the name of the inventory
*/
@Override
public String getInventoryName()
{
return "container.dire";
}
/**
* Returns if the inventory is named
*/
@Override
public boolean hasCustomInventoryName()
{
return false;
}
public int[] getAccessibleSlotsFromSide(int side){
return new int[]{};
}
public boolean canInsertItem(int slot, ItemStack item, int side){
return false;
}
public boolean canExtractItem(int slot, ItemStack item, int side){
return false;
}
}