mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-11 15:57:31 +00:00
Almost done with Auto Chisel
This commit is contained in:
1 parent
91cf0cf498
commit
5575d2dfcc
8 files changed
+87
-34
No files matched your search
+65
-6
@@ -1,7 +1,10 @@
|
||||
package info.jbcs.minecraft.chisel.block.tileentity;
|
||||
|
||||
import info.jbcs.minecraft.chisel.carving.Carving;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -15,11 +18,6 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory{
|
||||
private ItemStack[] inventory = new ItemStack[3];
|
||||
private String name = "autoChisel";
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int size) {
|
||||
if (inventory[slot] != null) {
|
||||
@@ -38,6 +36,32 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory{
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack increaseStackInSlot(ItemStack stack, int slot, int size){
|
||||
if(inventory[slot] != null){
|
||||
ItemStack is;
|
||||
|
||||
if(inventory[slot].stackSize == 0){
|
||||
inventory[slot] = stack;
|
||||
}
|
||||
|
||||
if(inventory[slot].stackSize <= size){
|
||||
is = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return is;
|
||||
} else {
|
||||
is = inventory[slot].splitStack(size);
|
||||
|
||||
if(inventory[slot].stackSize == 0){
|
||||
inventory[slot] = null;
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
@@ -59,6 +83,41 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
if(!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0){
|
||||
if(getStackInSlot(0) == null){
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack[] stacksInSlots = new ItemStack[inventory.length];
|
||||
|
||||
for(int c = 1; c < getSizeInventory() - 1; c++){
|
||||
stacksInSlots[c - 1] = getStackInSlot(c);
|
||||
}
|
||||
|
||||
ItemStack output = stacksInSlots[2];
|
||||
|
||||
if(!(stacksInSlots[0] == null || stacksInSlots[1] == null)){
|
||||
if(output == null) {
|
||||
if (stacksInSlots[0].stackSize > 0) {
|
||||
output = stacksInSlots[1].copy();
|
||||
stacksInSlots[0].stackSize--;
|
||||
}
|
||||
} else {
|
||||
if (stacksInSlots[0].stackSize > 0) {
|
||||
output.stackSize++;
|
||||
stacksInSlots[0].stackSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
@@ -150,7 +209,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory{
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemStack){
|
||||
return true;
|
||||
return slot != 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package info.jbcs.minecraft.chisel.compat;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import info.jbcs.minecraft.chisel.ChiselModCompatibility;
|
||||
import info.jbcs.minecraft.chisel.carving.Carving;
|
||||
|
||||
public class Compatibility
|
||||
@@ -11,7 +10,7 @@ public class Compatibility
|
||||
|
||||
public static void init(FMLPostInitializationEvent event)
|
||||
{
|
||||
new ChiselModCompatibility().postInit(event);
|
||||
new MarbleCompatibility().postInit(event);
|
||||
|
||||
addSupport("ProjRed|Exploration", "projectred.exploration.stone", "marble", 0, 99);
|
||||
addSupport("bluepower", "marble", "marble", 0, 99);
|
||||
|
||||
@@ -9,19 +9,14 @@ import net.minecraft.item.ItemStack;
|
||||
public class FMPIntegration implements IModIntegration{
|
||||
@Override
|
||||
public String getModId(){
|
||||
return "ForgeMultipart";
|
||||
return "ForgeMicroblock";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit(){
|
||||
registerMaterial(ModBlocks.marble);
|
||||
registerMaterial(ModBlocks.marbleSlab);
|
||||
registerMaterial(ModBlocks.marblePillar);
|
||||
registerMaterial(ModBlocks.marblePillarSlab);
|
||||
registerMaterial(ModBlocks.marbleStairs);
|
||||
registerMaterial(ModBlocks.limestone);
|
||||
registerMaterial(ModBlocks.limestoneSlab);
|
||||
registerMaterial(ModBlocks.limestoneStairs);
|
||||
registerMaterial(ModBlocks.cobblestone);
|
||||
registerMaterial(ModBlocks.glass);
|
||||
registerMaterial(ModBlocks.sandstone, 3, 15);
|
||||
@@ -40,22 +35,17 @@ public class FMPIntegration implements IModIntegration{
|
||||
registerMaterial(ModBlocks.dirt, 0, 12);
|
||||
registerMaterial(ModBlocks.ice, 1, 15);
|
||||
registerMaterial(ModBlocks.icePillar);
|
||||
registerMaterial(ModBlocks.iceStairs);
|
||||
registerMaterial(ModBlocks.obsidian, 1, 15);
|
||||
registerMaterial(ModBlocks.paneIron, 1, 9);
|
||||
registerMaterial(ModBlocks.redstone, 1, 15);
|
||||
registerMaterial(ModBlocks.holystone, 0, 13);
|
||||
registerMaterial(ModBlocks.lavastone, 0, 6);
|
||||
registerMaterial(ModBlocks.fantasy);
|
||||
registerMaterial(ModBlocks.carpet);
|
||||
registerMaterial(ModBlocks.carpetFloor);
|
||||
registerMaterial(ModBlocks.bookshelf, 0, 8);
|
||||
registerMaterial(ModBlocks.tyrian);
|
||||
registerMaterial(ModBlocks.temple);
|
||||
registerMaterial(ModBlocks.templeMossy);
|
||||
registerMaterial(ModBlocks.cloud, 0, 0);
|
||||
registerMaterial(ModBlocks.factory);
|
||||
registerMaterial(ModBlocks.paperWall, 0, 8);
|
||||
registerMaterial(ModBlocks.laboratory);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package info.jbcs.minecraft.chisel;
|
||||
package info.jbcs.minecraft.chisel.compat;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import info.jbcs.minecraft.chisel.carving.Carving;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ChiselModCompatibility
|
||||
public class MarbleCompatibility
|
||||
{
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ModBlocks {
|
||||
public static void load()
|
||||
{
|
||||
if(Configurations.featureEnabled("autoChisel")){
|
||||
autoChisel = new BlockAutoChisel().setBlockTextureName("Chisel:autoChisel").setCreativeTab(CreativeTabs.tabTools);
|
||||
autoChisel = new BlockAutoChisel().setBlockTextureName("Chisel:autoChisel").setCreativeTab(ModTabs.tabChisel);
|
||||
GameRegistry.registerBlock(autoChisel, autoChisel.getUnlocalizedName());
|
||||
Chisel.proxy.registerTileEntities();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import info.jbcs.minecraft.chisel.item.ItemBallOMoss;
|
||||
import info.jbcs.minecraft.chisel.item.ItemChisel;
|
||||
import info.jbcs.minecraft.chisel.item.ItemCloudInABottle;
|
||||
import info.jbcs.minecraft.chisel.item.ItemSmashingRock;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
public class ModItems {
|
||||
public static ItemChisel chisel;
|
||||
@@ -20,26 +19,26 @@ public class ModItems {
|
||||
public static ItemSmashingRock smashingRock;
|
||||
|
||||
public static void load(){
|
||||
chisel = (ItemChisel) new ItemChisel().setTextureName("chisel:chisel").setCreativeTab(CreativeTabs.tabTools);
|
||||
chisel = (ItemChisel) new ItemChisel().setTextureName("chisel:chisel").setCreativeTab(ModTabs.tabChisel);
|
||||
GameRegistry.registerItem(chisel, "chisel");
|
||||
|
||||
if(Configurations.featureEnabled("cloud"))
|
||||
{
|
||||
itemCloudInABottle = (ItemCloudInABottle) new ItemCloudInABottle().setTextureName("Chisel:cloudinabottle").setCreativeTab(CreativeTabs.tabTools);
|
||||
itemCloudInABottle = (ItemCloudInABottle) new ItemCloudInABottle().setTextureName("Chisel:cloudinabottle").setCreativeTab(ModTabs.tabChisel);
|
||||
EntityRegistry.registerModEntity(EntityCloudInABottle.class, "CloudInABottle", 1, Chisel.instance, 40, 1, true);
|
||||
GameRegistry.registerItem(itemCloudInABottle, "cloudinabottle");
|
||||
}
|
||||
|
||||
if(Configurations.featureEnabled("ballOfMoss"))
|
||||
{
|
||||
itemBallOMoss = (ItemBallOMoss) new ItemBallOMoss().setTextureName("Chisel:ballomoss").setCreativeTab(CreativeTabs.tabTools);
|
||||
itemBallOMoss = (ItemBallOMoss) new ItemBallOMoss().setTextureName("Chisel:ballomoss").setCreativeTab(ModTabs.tabChisel);
|
||||
EntityRegistry.registerModEntity(EntityBallOMoss.class, "BallOMoss", 2, Chisel.instance, 40, 1, true);
|
||||
GameRegistry.registerItem(itemBallOMoss, "ballomoss");
|
||||
}
|
||||
|
||||
if(Configurations.featureEnabled("smashingRock"))
|
||||
{
|
||||
smashingRock = (ItemSmashingRock) new ItemSmashingRock().setTextureName("Chisel:smashingrock").setCreativeTab(CreativeTabs.tabTools);
|
||||
smashingRock = (ItemSmashingRock) new ItemSmashingRock().setTextureName("Chisel:smashingrock").setCreativeTab(ModTabs.tabChisel);
|
||||
EntityRegistry.registerModEntity(EntitySmashingRock.class, "SmashingRock", 2, Chisel.instance, 40, 1, true);
|
||||
GameRegistry.registerItem(smashingRock, "smashingrock");
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@ public class ModTabs {
|
||||
tabChisel = new CreativeTabs("tabChisel")
|
||||
{
|
||||
@Override
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return Item.getItemFromBlock(ModBlocks.holystone);
|
||||
public Item getTabIconItem() {
|
||||
return ModItems.chisel;
|
||||
}
|
||||
};
|
||||
|
||||
tabChiselBlocks = new CreativeTabs("tabChiselBlocks") {
|
||||
@Override
|
||||
public Item getTabIconItem() {
|
||||
return ModItems.chisel;
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return Item.getItemFromBlock(ModBlocks.holystone);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ public class ContainerAutoChisel extends Container {
|
||||
autoChisel = tileEntityAutoChisel;
|
||||
|
||||
addSlotToContainer(new Slot(tileEntityAutoChisel, 0, 53, 15));
|
||||
addSlotToContainer(new Slot(tileEntityAutoChisel, 1, 103, 15));
|
||||
addSlotToContainer(new Slot(tileEntityAutoChisel, 2, 78, 51));
|
||||
addSlotToContainer(new Slot(tileEntityAutoChisel, 1, 78, 51));
|
||||
addSlotToContainer(new Slot(tileEntityAutoChisel, 2, 103, 15));
|
||||
|
||||
bindPlayerInventory(player);
|
||||
}
|
||||
@@ -50,6 +50,12 @@ public class ContainerAutoChisel extends Container {
|
||||
ItemStack stackInSlot = slotObject.getStack();
|
||||
stack = stackInSlot.copy();
|
||||
|
||||
if(slot == 2){
|
||||
if(!this.mergeItemStack(stackInSlot, 3, 39, true)){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(slot < autoChisel.getSizeInventory()){
|
||||
if(!this.mergeItemStack(stackInSlot, 0, 35, true)){
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user