mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-16 10:45:02 +00:00
Auto Chisel work
This commit is contained in:
1 parent
31c2e526de
commit
0a9f604231
6 files changed
+101
-96
No files matched your search
@@ -54,21 +54,6 @@ public class BlockAutoChisel extends BlockContainer{
|
||||
player.openGui(Chisel.instance, 1, world, x, y, z);
|
||||
}
|
||||
|
||||
if(player.isSneaking() && tile!= null && tile instanceof TileEntityAutoChisel){
|
||||
TileEntityAutoChisel autoChisel = (TileEntityAutoChisel) tile;
|
||||
System.out.println(player.getHeldItem());
|
||||
if(player.getItemInUse() == new ItemStack(ModItems.upgrade, 1, 0)){
|
||||
//If they are using the speed upgrade
|
||||
world.setBlock(x, y, z, ModBlocks.autoChisel, 1, 3);
|
||||
} else if(player.getItemInUse() == new ItemStack(ModItems.upgrade, 1, 1)){
|
||||
//If they are using the automation upgrade
|
||||
world.setBlock(x, y, z, ModBlocks.autoChisel, 2, 3);
|
||||
} else if(player.getItemInUse() == new ItemStack(ModItems.upgrade, 1, 2)){
|
||||
//If they are using the stack upgrade
|
||||
world.setBlock(x, y, z, ModBlocks.autoChisel, 3, 3);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,19 +63,6 @@ public class BlockAutoChisel extends BlockContainer{
|
||||
super.breakBlock(world, x, y, z, block, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata){
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List subItems){
|
||||
for(int x = 0; x < 4; x++){
|
||||
subItems.add(new ItemStack(this, 1, x));
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItems(World world, int x, int y, int z) {
|
||||
Random random = new Random();
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ItemBlockAutoChisel extends ItemBlock{
|
||||
|
||||
private final String[] names = {"base", "speed", "automation", "stack"};
|
||||
private int metadata;
|
||||
|
||||
public ItemBlockAutoChisel(Block block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta){
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack){
|
||||
return getUnlocalizedName() + "." + names[itemStack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4){
|
||||
list.add(StatCollector.translateToLocal(getUnlocalizedName() + "." + names[itemStack.getItemDamage()] + ".desc"));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.cricketcraft.chisel.block.tileentity;
|
||||
|
||||
import com.cricketcraft.chisel.block.BlockCarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.init.ModItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -16,9 +20,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityAutoChisel extends TileEntity implements ISidedInventory {
|
||||
|
||||
private final int BASE = 0, TARGET = 1, OUTPUT = 2, AUTOMATION = 3, STACK = 4, SPEED = 5;
|
||||
private boolean isAutomated, isStackMode, isFaster;
|
||||
private static EntityItem ghostItem;
|
||||
boolean equal = false;
|
||||
private ItemStack[] inventory = new ItemStack[3];
|
||||
private ItemStack[] inventory = new ItemStack[6];
|
||||
private String name = "autoChisel";
|
||||
|
||||
@Override
|
||||
@@ -66,44 +72,97 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) {
|
||||
if (inventory[0] != null && inventory[1] != null) {
|
||||
if (inventory[0].getItem() instanceof ItemBlock && inventory[1].getItem() instanceof ItemBlock) {
|
||||
if (inventory[0].getItem() == inventory[1].getItem()) {
|
||||
equal = true;
|
||||
} else {
|
||||
equal = false;
|
||||
}
|
||||
if (equal) {
|
||||
if (inventory[0].stackSize < 0) {
|
||||
inventory[0] = null;
|
||||
}
|
||||
|
||||
if (inventory[1].stackSize < 0) {
|
||||
inventory[1] = null;
|
||||
}
|
||||
if(inventory[SPEED] == new ItemStack(ModItems.upgrade, 1, 0)){
|
||||
isFaster = true;
|
||||
} else {
|
||||
isFaster = false;
|
||||
}
|
||||
|
||||
if (inventory[1].stackSize < 0) {
|
||||
inventory[1] = null;
|
||||
}
|
||||
if(inventory[AUTOMATION] == new ItemStack(ModItems.upgrade, 1, 1)){
|
||||
isAutomated = true;
|
||||
} else {
|
||||
isAutomated = false;
|
||||
}
|
||||
|
||||
if (inventory[2] == null) {
|
||||
setInventorySlotContents(2, new ItemStack(inventory[1].getItem(), 1, inventory[1].getItemDamage()));
|
||||
decrStackSize(0, 1);
|
||||
if(inventory[STACK] == new ItemStack(ModItems.upgrade, 1, 2)){
|
||||
isStackMode = true;
|
||||
} else {
|
||||
isStackMode = false;
|
||||
}
|
||||
|
||||
if(isFaster){
|
||||
if(!worldObj.isRemote && worldObj.getWorldTime() % 10 == 0){
|
||||
doTransaction();
|
||||
}
|
||||
} else {
|
||||
if(!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0){
|
||||
doTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
private void doTransaction(){
|
||||
if(!(isSlotNull(BASE) && !(isSlotNull(TARGET)))){
|
||||
if(inventory[BASE].getItem() instanceof ItemBlock && inventory[TARGET].getItem() instanceof ItemBlock){
|
||||
Block base = Block.getBlockFromItem(inventory[BASE].getItem());
|
||||
Block target = Block.getBlockFromItem(inventory[TARGET].getItem());
|
||||
|
||||
if(base instanceof BlockCarvable){
|
||||
BlockCarvable baseCarvable = (BlockCarvable) base;
|
||||
|
||||
if(baseCarvable.carverHelper.variations.contains(target)){
|
||||
if(isStackMode){
|
||||
if(inventory[BASE].stackSize == inventory[BASE].getMaxStackSize()){
|
||||
if(isSlotNull(OUTPUT)){
|
||||
inventory[OUTPUT] = inventory[BASE];
|
||||
inventory[BASE] = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (inventory[0].stackSize != 0 && inventory[2].stackSize <= getInventoryStackLimit()) {
|
||||
decrStackSize(0, 1);
|
||||
inventory[2].stackSize++;
|
||||
} else {
|
||||
inventory[0] = null;
|
||||
if(isSlotNull(OUTPUT)){
|
||||
inventory[OUTPUT] = new ItemStack(base, 1, inventory[BASE].getItemDamage());
|
||||
inventory[BASE].stackSize--;
|
||||
} else if(inventory[BASE].stackSize != 0){
|
||||
inventory[OUTPUT].stackSize++;
|
||||
inventory[BASE].stackSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(target instanceof BlockCarvable){
|
||||
BlockCarvable targetCarvable = (BlockCarvable) target;
|
||||
|
||||
if(targetCarvable.carverHelper.variations.contains(base)){
|
||||
if(isStackMode){
|
||||
if(inventory[BASE].stackSize == inventory[BASE].getMaxStackSize()){
|
||||
if(isSlotNull(OUTPUT)){
|
||||
inventory[OUTPUT] = inventory[BASE];
|
||||
inventory[BASE] = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(isSlotNull(OUTPUT)){
|
||||
inventory[OUTPUT] = new ItemStack(base, 1, inventory[BASE].getItemDamage());
|
||||
inventory[BASE].stackSize--;
|
||||
} else if(inventory[BASE].stackSize != 0){
|
||||
inventory[OUTPUT].stackSize++;
|
||||
inventory[BASE].stackSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
markDirty();
|
||||
private boolean isSlotNull(int slot){
|
||||
if(inventory[slot] == null){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,7 +238,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[3];
|
||||
return new int[6];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,12 +248,22 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
||||
if(isAutomated){
|
||||
if(side != 0 || side != 1 && slot == BASE){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
||||
return true;
|
||||
if(isAutomated){
|
||||
if(side == 0 || side == 1 && slot == OUTPUT){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,7 +76,6 @@ public class FMPIntegration implements IModIntegration{
|
||||
registerMaterial(ModBlocks.factory, 0, 12);
|
||||
registerMaterial(ModBlocks.factory, 14, 14);
|
||||
registerMaterial(ModBlocks.stainedGlass[0]); //White
|
||||
registerMaterial(ModBlocks.stainedGlass[4]); //Yellow
|
||||
registerMaterial(ModBlocks.stainedGlass[8]); //Light Gray
|
||||
registerMaterial(ModBlocks.stainedGlass[12]); //Brown
|
||||
registerMaterial(ModBlocks.woolenClay);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ModBlocks {
|
||||
{
|
||||
if(Configurations.featureEnabled("autoChisel")){
|
||||
autoChisel = new BlockAutoChisel().setBlockTextureName("Chisel:autoChisel").setCreativeTab(ModTabs.tabChisel).setBlockName("autoChisel").setBlockTextureName(Chisel.MOD_ID + ":factory/circuit");
|
||||
GameRegistry.registerBlock(autoChisel, ItemBlockAutoChisel.class, "autoChisel");
|
||||
GameRegistry.registerBlock(autoChisel, "autoChisel");
|
||||
Chisel.proxy.registerTileEntities();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
|
||||
public class ItemUpgrade extends BaseItem{
|
||||
|
||||
public IIcon[] icons = new IIcon[6];
|
||||
public IIcon[] icons = new IIcon[3];
|
||||
|
||||
public ItemUpgrade(String unlocalizedName) {
|
||||
super();
|
||||
|
||||
Reference in new issue
Block a user