Attempting fix of a dumb conflict.

This commit is contained in:
Alex Spinks committed 2015-08-06 21:32:44 +01:00
commit 2560663dff
10 files changed
+377 -23

No files matched your search

@@ -3,15 +3,25 @@ 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.TileEntityDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityNeutron;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockDireCrafting extends Block {
import java.util.Random;
public class BlockDireCrafting extends BlockContainer {
private static IIcon top, sides, bottom;
private Random randy = new Random();
public BlockDireCrafting(){
super(Material.iron);
@@ -56,4 +66,53 @@ public class BlockDireCrafting extends Block {
return true;
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityDireCrafting();
}
public void breakBlock(World world, int x, int y, int z, Block block, int wut)
{
TileEntityDireCrafting craft = (TileEntityDireCrafting)world.getTileEntity(x, y, z);
if (craft != null)
{
for(int i = 1;i < 82;i++) {
ItemStack itemstack = craft.getStackInSlot(i);
if (itemstack != null) {
float f = this.randy.nextFloat() * 0.8F + 0.1F;
float f1 = this.randy.nextFloat() * 0.8F + 0.1F;
float f2 = this.randy.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0) {
int j1 = this.randy.nextInt(21) + 10;
if (j1 > itemstack.stackSize) {
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (double) ((float) this.randy.nextGaussian() * f3);
entityitem.motionY = (double) ((float) this.randy.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double) ((float) this.randy.nextGaussian() * f3);
world.spawnEntityInWorld(entityitem);
}
}
world.func_147453_f(x, y, z, block);
}
}
super.breakBlock(world, x, y, z, block, wut);
}
}
@@ -85,9 +85,7 @@ public class BlockNeutronCollector extends BlockContainer {
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityNeutron();
@@ -1,6 +1,7 @@
package fox.spiteful.avaritia.blocks;
import cpw.mods.fml.common.registry.GameRegistry;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityNeutron;
import net.minecraft.block.Block;
@@ -21,6 +22,7 @@ public class LudicrousBlocks {
crystal_matrix = GameRegistry.registerBlock(new BlockCrystalMatrix(), "Crystal_Matrix");
resource_block = GameRegistry.registerBlock(new BlockResource(), ItemBlockResource.class, "Resource_Block");
dire_crafting = GameRegistry.registerBlock(new BlockDireCrafting(), "Dire_Crafting");
GameRegistry.registerTileEntity(TileEntityDireCrafting.class, "Avaritia_Dire_Craft");
neutron_collector = GameRegistry.registerBlock(new BlockNeutronCollector(), "Neutron_Collector");
GameRegistry.registerTileEntity(TileEntityNeutron.class, "Avaritia_Neutron");
}
@@ -2,6 +2,9 @@ package fox.spiteful.avaritia.gui;
import fox.spiteful.avaritia.blocks.LudicrousBlocks;
import fox.spiteful.avaritia.crafting.ExtremeCraftingManager;
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.init.Blocks;
@@ -13,19 +16,21 @@ import net.minecraft.world.World;
public class ContainerExtremeCrafting extends Container {
/** The crafting matrix inventory (9x9). */
public InventoryCrafting craftMatrix = new InventoryCrafting(this, 9, 9);
public IInventory craftResult = new InventoryCraftResult();
public InventoryCrafting craftMatrix;
public IInventory craftResult;
private World worldObj;
private int posX;
private int posY;
private int posZ;
public ContainerExtremeCrafting(InventoryPlayer player, World world, int x, int y, int z)
public ContainerExtremeCrafting(InventoryPlayer player, World world, int x, int y, int z, TileEntityDireCrafting 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;
@@ -69,18 +74,6 @@ public class ContainerExtremeCrafting extends Container {
{
super.onContainerClosed(player);
if (!this.worldObj.isRemote)
{
for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
{
ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
if (itemstack != null)
{
player.dropPlayerItemWithRandomChoice(itemstack, false);
}
}
}
}
public boolean canInteractWith(EntityPlayer player)
@@ -1,5 +1,6 @@
package fox.spiteful.avaritia.gui;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
@@ -11,9 +12,9 @@ public class GUIExtremeCrafting extends GuiContainer {
private static final ResourceLocation tex = new ResourceLocation("avaritia:textures/gui/dire_crafting_gui.png");
public GUIExtremeCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
public GUIExtremeCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int x, int y, int z, TileEntityDireCrafting table)
{
super(new ContainerExtremeCrafting(par1InventoryPlayer, par2World, par3, par4, par5));
super(new ContainerExtremeCrafting(par1InventoryPlayer, par2World, x, y, z, table));
this.ySize = 256;
this.xSize = 238;
}
@@ -1,6 +1,7 @@
package fox.spiteful.avaritia.gui;
import cpw.mods.fml.common.network.IGuiHandler;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import fox.spiteful.avaritia.tile.TileEntityNeutron;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.entity.player.EntityPlayer;
@@ -13,7 +14,7 @@ public class GooeyHandler implements IGuiHandler {
if(ID == 0)
return new GuiCrafting(player.inventory, world, x, y, z);
else if(ID == 1)
return new GUIExtremeCrafting(player.inventory, world, x, y, z);
return new GUIExtremeCrafting(player.inventory, world, x, y, z, (TileEntityDireCrafting)world.getTileEntity(x, y, z));
else if(ID == 2)
return new GUINeutron(player.inventory, (TileEntityNeutron)world.getTileEntity(x, y, z));
return null;
@@ -24,7 +25,7 @@ public class GooeyHandler implements IGuiHandler {
if(ID == 0)
return new ContainerCustomWorkbench(player.inventory, world, x, y, z);
else if(ID == 1)
return new ContainerExtremeCrafting(player.inventory, world, x, y, z);
return new ContainerExtremeCrafting(player.inventory, world, x, y, z, (TileEntityDireCrafting)world.getTileEntity(x, y, z));
else if(ID == 2)
return new ContainerNeutron(player.inventory, (TileEntityNeutron)world.getTileEntity(x, y, z));
return null;
@@ -0,0 +1,165 @@
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 TileEntityDireCrafting extends TileLudicrous implements IInventory, ISidedInventory{
private ItemStack result;
private ItemStack[] matrix = new ItemStack[81];
@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;
}
}
@@ -50,6 +50,8 @@ public class TileEntityNeutron extends TileLudicrous implements IInventory {
neutrons.writeToNBT(produce);
tag.setTag("Neutrons", produce);
}
else
tag.removeTag("Neutrons");
}
@Override
@@ -0,0 +1,49 @@
package fox.spiteful.avaritia.tile.inventory;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.item.ItemStack;
public class InventoryDireCraftResult extends InventoryCraftResult {
private TileEntityDireCrafting craft;
public InventoryDireCraftResult(TileEntityDireCrafting table){
craft = table;
}
@Override
public ItemStack getStackInSlot (int par1)
{
return craft.getStackInSlot(0);
}
@Override
public ItemStack decrStackSize (int par1, int par2)
{
ItemStack stack = craft.getStackInSlot(0);
if (stack != null)
{
ItemStack itemstack = stack;
craft.setInventorySlotContents(0, null);
return itemstack;
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing (int par1)
{
return null;
}
@Override
public void setInventorySlotContents (int par1, ItemStack par2ItemStack)
{
craft.setInventorySlotContents(0, par2ItemStack);
}
}
@@ -0,0 +1,84 @@
package fox.spiteful.avaritia.tile.inventory;
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
public class InventoryDireCrafting extends InventoryCrafting {
private TileEntityDireCrafting craft;
private Container container;
public InventoryDireCrafting(Container cont, TileEntityDireCrafting table){
super(cont, 9, 9);
craft = table;
container = cont;
}
@Override
public ItemStack getStackInSlot (int slot)
{
return slot >= this.getSizeInventory() ? null : craft.getStackInSlot(slot+1);
}
@Override
public ItemStack getStackInRowAndColumn (int row, int column)
{
if (row >= 0 && row < 9)
{
int x = row + column * 9;
return this.getStackInSlot(x);
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing (int par1)
{
return null;
}
@Override
public ItemStack decrStackSize (int slot, int decrement)
{
ItemStack stack = craft.getStackInSlot(slot + 1);
if (stack != null)
{
ItemStack itemstack;
if (stack.stackSize <= decrement)
{
itemstack = stack.copy();
stack = null;
craft.setInventorySlotContents(slot + 1, null);
this.container.onCraftMatrixChanged(this);
return itemstack;
}
else
{
itemstack = stack.splitStack(decrement);
if (stack.stackSize == 0)
{
stack = null;
}
this.container.onCraftMatrixChanged(this);
return itemstack;
}
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
craft.setInventorySlotContents(slot + 1, itemstack);
this.container.onCraftMatrixChanged(this);
}
}