Some more work on the calcinator
This commit is contained in:
parent
79abcd0991
commit
455307b193
5 changed files with 57 additions and 4 deletions
|
@ -1,10 +1,14 @@
|
||||||
package com.pahimar.ee3.block;
|
package com.pahimar.ee3.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -25,6 +29,11 @@ import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||||
*/
|
*/
|
||||||
public class BlockCalcinator extends BlockEE {
|
public class BlockCalcinator extends BlockEE {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the random generator used by calcinator to drop the inventory contents in random directions.
|
||||||
|
*/
|
||||||
|
private Random rand = new Random();
|
||||||
|
|
||||||
public BlockCalcinator(int id) {
|
public BlockCalcinator(int id) {
|
||||||
|
|
||||||
super(id, Material.rock);
|
super(id, Material.rock);
|
||||||
|
@ -66,6 +75,7 @@ public class BlockCalcinator extends BlockEE {
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
||||||
|
|
||||||
|
dropInventory(world, x, y, z);
|
||||||
super.breakBlock(world, x, y, z, id, meta);
|
super.breakBlock(world, x, y, z, id, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +94,6 @@ public class BlockCalcinator extends BlockEE {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dropInventory(World world, int x, int y, int z) {
|
private void dropInventory(World world, int x, int y, int z) {
|
||||||
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (!(tileEntity instanceof IInventory)) {
|
if (!(tileEntity instanceof IInventory)) {
|
||||||
|
@ -99,7 +108,22 @@ public class BlockCalcinator extends BlockEE {
|
||||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
ItemStack itemStack = inventory.getStackInSlot(i);
|
||||||
|
|
||||||
if ((itemStack != null) && (itemStack.stackSize > 0)) {
|
if ((itemStack != null) && (itemStack.stackSize > 0)) {
|
||||||
|
float dX = this.rand.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float dY = this.rand.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float dZ = this.rand.nextFloat() * 0.8F + 0.1F;
|
||||||
|
|
||||||
|
EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, new ItemStack(itemStack.itemID, itemStack.stackSize, itemStack.getItemDamage()));
|
||||||
|
|
||||||
|
if (itemStack.hasTagCompound()) {
|
||||||
|
entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
float factor = 0.05F;
|
||||||
|
entityItem.motionX = (this.rand.nextGaussian() * factor);
|
||||||
|
entityItem.motionY = (this.rand.nextGaussian() * factor + 0.2F);
|
||||||
|
entityItem.motionZ = (this.rand.nextGaussian() * factor);
|
||||||
|
world.spawnEntityInWorld(entityItem);
|
||||||
|
itemStack.stackSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class ContainerCalcinator extends Container {
|
||||||
this.addSlotToContainer(new Slot(calcinator, 1, 56, 62));
|
this.addSlotToContainer(new Slot(calcinator, 1, 56, 62));
|
||||||
|
|
||||||
// Add the calcined results slot to the container
|
// Add the calcined results slot to the container
|
||||||
// TODO Add a slot here
|
this.addSlotToContainer(new SlotCalcinator(calcinator, 2, 116, 35));
|
||||||
|
|
||||||
// Add the player's inventory slots to the container
|
// Add the player's inventory slots to the container
|
||||||
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
|
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
|
||||||
|
@ -52,7 +52,6 @@ public class ContainerCalcinator extends Container {
|
||||||
|
|
||||||
public boolean canInteractWith(EntityPlayer player) {
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
|
|
||||||
//return calcinator.isUseableByPlayer(player);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
ee3_common/com/pahimar/ee3/inventory/SlotCalcinator.java
Normal file
18
ee3_common/com/pahimar/ee3/inventory/SlotCalcinator.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package com.pahimar.ee3.inventory;
|
||||||
|
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class SlotCalcinator extends Slot {
|
||||||
|
|
||||||
|
public SlotCalcinator(IInventory inventory, int x, int y, int z) {
|
||||||
|
|
||||||
|
super(inventory, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.pahimar.ee3.item.crafting;
|
||||||
|
|
||||||
|
|
||||||
|
public class CalcinationManager {
|
||||||
|
|
||||||
|
private static final CalcinationManager calcinationBase = new CalcinationManager();
|
||||||
|
|
||||||
|
public static final CalcinationManager calcination() {
|
||||||
|
|
||||||
|
return calcinationBase;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pahimar.ee3.transmutation;
|
package com.pahimar.ee3.item.crafting;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
Loading…
Reference in a new issue