diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockPlant.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPlant.java index 6de887356..d08f25789 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockPlant.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPlant.java @@ -16,12 +16,17 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import powercrystals.minefactoryreloaded.api.FertilizerType; +import powercrystals.minefactoryreloaded.api.HarvestType; +import powercrystals.minefactoryreloaded.api.IFactoryFertilizable; +import powercrystals.minefactoryreloaded.api.IFactoryHarvestable; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Random; -public class BlockPlant extends BlockCrops implements INameableItem{ +public class BlockPlant extends BlockCrops implements INameableItem, IFactoryHarvestable, IFactoryFertilizable{ private IIcon[] textures; private String name; @@ -58,7 +63,6 @@ public class BlockPlant extends BlockCrops implements INameableItem{ return null; } - @Override public boolean canPlaceBlockOn(Block block){ return block == ((ItemSeed)this.seedItem).soilBlock; @@ -135,4 +139,57 @@ public class BlockPlant extends BlockCrops implements INameableItem{ return damage; } } + + @Override + public Block getPlant(){ + return this; + } + + @Override + public boolean canFertilize(World world, int x, int y, int z, FertilizerType fertilizerType){ + return true; + } + + @Override + public boolean fertilize(World world, Random rand, int x, int y, int z, FertilizerType fertilizerType){ + if (this.func_149851_a(world, x, y, z, world.isRemote)){ + if(!world.isRemote){ + if(this.func_149852_a(world, world.rand, x, y, z)){ + this.func_149853_b(world, world.rand, x, y, z); + return true; + } + } + } + return false; + } + + @Override + public HarvestType getHarvestType(){ + return HarvestType.Normal; + } + + @Override + public boolean breakBlock(){ + return true; + } + + @Override + public boolean canBeHarvested(World world, Map harvesterSettings, int x, int y, int z){ + return world.getBlockMetadata(x, y, z) >= 7; + } + + @Override + public List getDrops(World world, Random rand, Map harvesterSettings, int x, int y, int z){ + return this.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + } + + @Override + public void preHarvest(World world, int x, int y, int z){ + + } + + @Override + public void postHarvest(World world, int x, int y, int z){ + + } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java index 64cdf3528..1835c493e 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java @@ -7,6 +7,7 @@ import net.minecraft.block.material.Material; import net.minecraft.item.EnumRarity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; +import powercrystals.minefactoryreloaded.api.FactoryRegistry; public class InitBlocks{ @@ -76,9 +77,13 @@ public class InitBlocks{ blockRice = new BlockPlant("blockRice", 6); BlockUtil.register(blockRice, BlockPlant.TheItemBlock.class, false); + FactoryRegistry.sendMessage("registerHarvestable", blockRice); + FactoryRegistry.sendMessage("registerFertilizable", blockRice); blockCanola = new BlockPlant("blockCanola", 4); BlockUtil.register(blockCanola, BlockPlant.TheItemBlock.class, false); + FactoryRegistry.sendMessage("registerHarvestable", blockCanola); + FactoryRegistry.sendMessage("registerFertilizable", blockCanola); blockCompost = new BlockCompost(); BlockUtil.register(blockCompost, BlockCompost.TheItemBlock.class); diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java index 571d2a6e0..42506dfdd 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java @@ -43,7 +43,7 @@ public enum ConfigIntValues{ HEAT_COLLECTOR_BLOCKS("Heat Collector: Blocks Needed", ConfigCategories.MACHINE_VALUES, 4, 1, 5, "How many Blocks are needed for the Heat Collector to power Machines above it"), HEAT_COLLECTOR_LAVA_CHANCE("Heat Collector: Random Chance", ConfigCategories.MACHINE_VALUES, 10000, 10, 100000, "The Chance of the Heat Collector destroying a Lava Block around (Default Value 2000 meaning a 1/2000 Chance!)"), - GLASS_TIME_NEEDED("Greenhouse Glass: Time Needed", ConfigCategories.MACHINE_VALUES, 4000, 10, 1000000, "The Time Needed for the Greenhouse Glass to grow a Plant below it"), + GLASS_TIME_NEEDED("Greenhouse Glass: Time", ConfigCategories.MACHINE_VALUES, 5000, 10, 1000000, "The Time Needed for the Greenhouse Glass to grow a Plant below it"), BREAKER_TIME_NEEDED("Breaker and Placer: Time Needed", ConfigCategories.MACHINE_VALUES, 15, 1, 10000, "The Time Needed for the Breaker and the Placer to place or break a Block"), DROPPER_TIME_NEEDED("Dropper: Time Needed", ConfigCategories.MACHINE_VALUES, 10, 1, 10000, "The Time Needed for the Dropper to drop an Item"), @@ -61,7 +61,7 @@ public enum ConfigIntValues{ FURNACE_ENERGY_USED("Energy Use: Double Furnace", ConfigCategories.MACHINE_VALUES, 25, 1, 500, "The Amount of Energy used by the Double Furnace per Tick"), PRESS_PROCESSING_TIME("Canola Press: Processing Time", ConfigCategories.MACHINE_VALUES, 30, 1, 1000, "The Amount of time it takes to process one Canola"), - PRESS_MB_PRODUCED("Canola Press: mB Produced", ConfigCategories.MACHINE_VALUES, 50, 1, 5000, "The Amount of Canola Oil produced from one Canola"), + PRESS_MB_PRODUCED("Canola Press: mB Produced", ConfigCategories.MACHINE_VALUES, 30, 1, 5000, "The Amount of Canola Oil produced from one Canola"), PRESS_ENERGY_USED("Energy Use: Canola Press", ConfigCategories.MACHINE_VALUES, 35, 10, 500, "The Amount of Energy used by the Canola Press per Tick"), BARREL_MB_PRODUCED("Fermenting Barrel: mB Produced", ConfigCategories.MACHINE_VALUES, 50, 1, 3000, "The Amount of mB produced by the Barrel per cycle"), diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java index 224a8f0dd..161cb37ef 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java @@ -50,28 +50,30 @@ public class ContainerBreaker extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 9+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 9, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java index 47dde5e19..095a9e254 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java @@ -50,28 +50,30 @@ public class ContainerDropper extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 9+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 9, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java index ae0d3528f..e17e0ba9a 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java @@ -79,28 +79,30 @@ public class ContainerFeeder extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 1, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFermentingBarrel.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFermentingBarrel.java index 85946bd3f..f1c01935c 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFermentingBarrel.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFermentingBarrel.java @@ -93,33 +93,35 @@ public class ContainerFermentingBarrel extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(currentStack.getItem() == InitItems.itemBucketCanolaOil){ - this.mergeItemStack(newStack, 0, 1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(currentStack.getItem() == InitItems.itemBucketCanolaOil){ + this.mergeItemStack(newStack, 0, 1, false); + } + if(currentStack.getItem() == Items.bucket){ + this.mergeItemStack(newStack, 2, 3, false); + } } - if(currentStack.getItem() == Items.bucket){ - this.mergeItemStack(newStack, 2, 3, false); + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); } - } - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ + else if(slot < inventoryStart){ this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java index b68c0b322..3ef872724 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java @@ -96,31 +96,33 @@ public class ContainerFurnaceDouble extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(FurnaceRecipes.smelting().getSmeltingResult(currentStack) != null){ - this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1+1, false); - this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2+2, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(FurnaceRecipes.smelting().getSmeltingResult(currentStack) != null){ + this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1+1, false); + this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2+2, false); + } } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java index 3d5d510a8..941b9ad60 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java @@ -50,28 +50,30 @@ public class ContainerGiantChest extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 117, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 117, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java index 296ca65f0..9047d05d0 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java @@ -102,31 +102,33 @@ public class ContainerGrinder extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(GrinderRecipes.instance().getOutput(currentStack, false) != null){ - this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_1, TileEntityGrinder.SLOT_INPUT_1+1, false); - if(this.isDouble) this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_2, TileEntityGrinder.SLOT_INPUT_2+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(GrinderRecipes.instance().getOutput(currentStack, false) != null){ + this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_1, TileEntityGrinder.SLOT_INPUT_1+1, false); + if(this.isDouble) this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_2, TileEntityGrinder.SLOT_INPUT_2+1, false); + } } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java index 648ea273a..b11a6ebc0 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java @@ -114,28 +114,30 @@ public class ContainerInputter extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 1, false); - } + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 1, false); + } - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd, false); - } + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd, false); + } - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd, false); - } + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd, false); + } - else if(slot < inventoryStart){ + else if(slot < inventoryStart){ this.mergeItemStack(newStack, inventoryStart, hotbarEnd, false); } - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); - return currentStack; + return currentStack; + } } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerOilGenerator.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerOilGenerator.java index e1164f9b7..570cac557 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerOilGenerator.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerOilGenerator.java @@ -90,30 +90,32 @@ public class ContainerOilGenerator extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(currentStack.getItem() == InitItems.itemBucketOil){ - this.mergeItemStack(newStack, 0, 1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(currentStack.getItem() == InitItems.itemBucketOil){ + this.mergeItemStack(newStack, 0, 1, false); + } } - } - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } - else if(slot < inventoryStart){ + else if(slot < inventoryStart){ this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java index 57a8a3f09..da2450df6 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java @@ -78,30 +78,32 @@ public class ContainerRepairer extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(TileEntityItemRepairer.canBeRepaired(currentStack)){ - this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_INPUT, TileEntityItemRepairer.SLOT_INPUT+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(TileEntityItemRepairer.canBeRepaired(currentStack)){ + this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_INPUT, TileEntityItemRepairer.SLOT_INPUT+1, false); + } } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java index 5f6354598..5c44e0ddd 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java +++ b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java @@ -15,6 +15,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.fluids.FluidContainerRegistry; +import powercrystals.minefactoryreloaded.api.FactoryRegistry; public class InitItems{ @@ -112,9 +113,11 @@ public class InitItems{ itemRiceSeed = new ItemSeed("itemRiceSeed", InitBlocks.blockRice, Blocks.water, EnumPlantType.Water, new ItemStack(itemFoods, 1, TheFoods.RICE.ordinal())); ItemUtil.register(itemRiceSeed); + FactoryRegistry.sendMessage("registerPlantable", itemRiceSeed); - itemCanolaSeed = new ItemSeed("itemCanolaSeed", InitBlocks.blockCanola, Blocks.grass, EnumPlantType.Crop, new ItemStack(itemMisc, 1, TheMiscItems.CANOLA.ordinal())); + itemCanolaSeed = new ItemSeed("itemCanolaSeed", InitBlocks.blockCanola, Blocks.grass, EnumPlantType.Plains, new ItemStack(itemMisc, 1, TheMiscItems.CANOLA.ordinal())); ItemUtil.register(itemCanolaSeed); + FactoryRegistry.sendMessage("registerPlantable", itemCanolaSeed); itemPickaxeEmerald = new ItemPickaxeAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemPickaxeEmerald", EnumRarity.rare); itemAxeEmerald = new ItemAxeAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemAxeEmerald", EnumRarity.rare); diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java b/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java index b02400107..28165a6c2 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java @@ -65,7 +65,7 @@ public class ItemPhantomConnector extends Item implements INameableItem{ @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ - if(KeyUtil.isControlPressed()) this.clearStorage(stack); + if(KeyUtil.isAltPressed()) this.clearStorage(stack); return stack; } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java b/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java index 872f9af7c..7f5d1c7d6 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java @@ -12,20 +12,22 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; +import net.minecraft.item.ItemSeeds; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; -import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.ForgeEventFactory; +import powercrystals.minefactoryreloaded.api.IFactoryPlantable; +import powercrystals.minefactoryreloaded.api.ReplacementBlock; import java.util.List; -public class ItemSeed extends Item implements IPlantable, INameableItem{ +public class ItemSeed extends ItemSeeds implements INameableItem, IFactoryPlantable{ public Block plant; public Block soilBlock; @@ -33,6 +35,7 @@ public class ItemSeed extends Item implements IPlantable, INameableItem{ public String name; public ItemSeed(String name, Block plant, Block soilBlock, EnumPlantType type, ItemStack returnItem){ + super(plant, soilBlock); this.name = name; this.plant = plant; this.soilBlock = soilBlock; @@ -64,7 +67,7 @@ public class ItemSeed extends Item implements IPlantable, INameableItem{ int j = pos.blockY; int k = pos.blockZ; - if(world.canMineBlock(player, i, j, k) && player.canPlayerEdit(i, j, k, pos.sideHit, stack)){ + if(player.canPlayerEdit(i, j, k, pos.sideHit, stack)){ if(world.getBlock(i, j, k).getMaterial() == Material.water && world.getBlockMetadata(i, j, k) == 0 && world.isAirBlock(i, j + 1, k)){ BlockSnapshot snap = BlockSnapshot.getBlockSnapshot(world, i, j+1, k); world.setBlock(i, j + 1, k, this.plant); @@ -127,4 +130,34 @@ public class ItemSeed extends Item implements IPlantable, INameableItem{ public String getOredictName(){ return this.getName(); } -} + + @Override + public Item getSeed(){ + return this; + } + + @Override + public boolean canBePlanted(ItemStack stack, boolean forFermenting){ + return true; + } + + @Override + public ReplacementBlock getPlantedBlock(World world, int x, int y, int z, ItemStack stack){ + return new ReplacementBlock(this.plant); + } + + @Override + public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack){ + return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && ((BlockPlant)this.plant).canPlaceBlockOn(world.getBlock(x, y-1, z)); + } + + @Override + public void prePlant(World world, int x, int y, int z, ItemStack stack){ + + } + + @Override + public void postPlant(World world, int x, int y, int z, ItemStack stack){ + + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java index c316ab395..ed1893a36 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java @@ -3,7 +3,6 @@ package ellpeck.actuallyadditions.tile; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChunkCoordinates; @@ -70,9 +69,9 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ this.markDirty(); } } - else if(this.isPlacer && (worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ).isReplaceable(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ))){ + else if(this.isPlacer && worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ).isReplaceable(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ)){ ItemStack removeFalse = this.removeFromInventory(false); - if(removeFalse != null && Block.getBlockFromItem(removeFalse.getItem()) != blockToBreak && WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, removeFalse)){ + if(removeFalse != null && WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, removeFalse)){ this.removeFromInventory(true); } } @@ -115,7 +114,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ public ItemStack removeFromInventory(boolean actuallyDo){ for(int i = 0; i < this.slots.length; i++){ - if(this.slots[i] != null && !(Block.getBlockFromItem(this.slots[i].getItem()) instanceof BlockAir)){ + if(this.slots[i] != null){ ItemStack slot = this.slots[i].copy(); if(actuallyDo){ this.slots[i].stackSize--; diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java index 69a778842..77ff04357 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java @@ -80,7 +80,6 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{ public IInventory getInventory(){ TileEntity tile = boundTile.getWorldObj().getTileEntity(boundTile.xCoord, boundTile.yCoord, boundTile.zCoord); if(tile != null && tile instanceof IInventory){ - this.markDirty(); return (IInventory)tile; } return null; @@ -113,6 +112,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{ @Override public void setInventorySlotContents(int i, ItemStack stack){ if(this.isBoundTileInRage()) this.getInventory().setInventorySlotContents(i, stack); + this.markDirty(); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java b/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java index 6a90f1b2c..ff35bbba2 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java @@ -2,13 +2,13 @@ package ellpeck.actuallyadditions.util; import cpw.mods.fml.common.registry.GameRegistry; import ellpeck.actuallyadditions.creative.CreativeTab; -import ellpeck.actuallyadditions.waila.WailaDataProvider; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; +import java.util.ArrayList; import java.util.List; public class BlockUtil{ @@ -41,6 +41,8 @@ public class BlockUtil{ } } + public static final ArrayList wailaRegisterList = new ArrayList(); + public static void register(Block block, Class itemBlock, Enum[] list){ block.setCreativeTab(CreativeTab.instance); block.setBlockName(createUnlocalizedName(block)); @@ -49,7 +51,7 @@ public class BlockUtil{ if(!((INameableItem)current).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)current).getOredictName(), new ItemStack(block, 1, current.ordinal())); } - WailaDataProvider.registerList.add(block); + wailaRegisterList.add(block); } public static void register(Block block, Class itemBlock){ @@ -62,7 +64,6 @@ public class BlockUtil{ GameRegistry.registerBlock(block, itemBlock, ((INameableItem)block).getName()); if(!((INameableItem)block).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)block).getOredictName(), new ItemStack(block, 1, Util.WILDCARD)); - WailaDataProvider.registerList.add(block); + wailaRegisterList.add(block); } - } diff --git a/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java b/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java index 7db820f5f..a455ca1fa 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java @@ -12,4 +12,8 @@ public class KeyUtil{ return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); } + public static boolean isAltPressed(){ + return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU); + } + } diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java index fa205740f..4d088e31d 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java @@ -8,6 +8,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.IFluidHandler; @@ -50,8 +51,13 @@ public class WorldUtil{ public static boolean placeBlockAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){ if(world instanceof WorldServer){ + if(stack.getItem() instanceof IPlantable){ + if(((IPlantable)stack.getItem()).getPlant(world, x, y, z).canPlaceBlockAt(world, x+side.offsetX, y+side.offsetY, z+side.offsetZ)){ + return world.setBlock(x+side.offsetX, y+side.offsetY, z+side.offsetZ, ((IPlantable)stack.getItem()).getPlant(world, x, y, z)); + } + } if(side != ForgeDirection.UNKNOWN){ - return stack.tryPlaceItemIntoWorld(FakePlayerUtil.newFakePlayer(world), world, x, y, z, side.ordinal(), 0, 0, 0); + return stack.tryPlaceItemIntoWorld(FakePlayerUtil.newFakePlayer(world), world,x, y, z, side.ordinal(), 0, 0, 0); } } return false; diff --git a/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java b/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java index da5b44583..8bf9f5272 100644 --- a/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java +++ b/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java @@ -3,6 +3,7 @@ package ellpeck.actuallyadditions.waila; import ellpeck.actuallyadditions.blocks.BlockCompost; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.tile.TileEntityCompost; +import ellpeck.actuallyadditions.util.BlockUtil; import ellpeck.actuallyadditions.util.INameableItem; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; @@ -18,7 +19,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import java.util.ArrayList; import java.util.List; @SuppressWarnings("unused") @@ -26,8 +26,6 @@ public class WailaDataProvider implements IWailaDataProvider{ private final String WAILA_PRE_LANG = "gui." + ModUtil.MOD_ID_LOWER + ".waila."; - public static final ArrayList registerList = new ArrayList(); - @Override public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config){ return null; @@ -90,7 +88,7 @@ public class WailaDataProvider implements IWailaDataProvider{ registrar.registerBodyProvider(provider, BlockCompost.class); - for(Block theBlock : registerList){ + for(Block theBlock : BlockUtil.wailaRegisterList){ registrar.registerHeadProvider(provider, theBlock.getClass()); } } diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java b/src/main/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java new file mode 100644 index 000000000..804d2999a --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java @@ -0,0 +1,113 @@ +package powercrystals.minefactoryreloaded.api; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +/** + * @author PowerCrystals + * + * Class used to register plants and other farming-related things with MFR. Will do nothing if MFR does not exist. + * + */ +public class FactoryRegistry +{ + /* + * This may be called at any time during pre-init, init or post-init, assuming all blocks and items + * that are being accessed from the registry have been appropriately registered. + * Possible messages: + * + * // Registration: + * addLaserPreferredOre | NBTTag with an ItemStack saved on it, with the color on the "value" attribute, + * | A ValuedItem with item and value set. + * registerAutoSpawnerBlacklist | The String identifier of an entity, + * | A subclass of EntityLivingBase. + * registerFertilizable | An instance of IFactoryFertilizable. + * registerFertilizer | An instance of IFactoryFertilizer. + * registerFruitLog | The String identifier of a block. + * registerGrindable | An instance of IFactoryGrindable. + * registerGrinderBlacklist | A subclass of EntityLivingBase. + * registerHarvestable | An instance of IFactoryHarvestable. + * registerLaserOre | NBTTag with an ItemStack saved on it, with the weight on the "value" attribute, + * | A ValuedItem with item and value set. + * registerLiquidDrinkHandler | A ValuedItem with key and object set; ILiquidDrinkHandler expected. + * registerMobEggHandler | An instance of IMobEggHandler. + * registerPickableFruit | An instance of IFactoryFruit. + * registerPlantable | An instance of IFactoryPlantable. + * registerRanchable | An instance of IFactoryRanchable. + * registerRedNetLogicCircuit | An instance of IRedNetLogicCircuit. + * registerRubberTreeBiome | The biomeName field of a biome to white list for rubber trees to spawn in. + * registerSafariNetBlacklist | A subclass of EntityLivingBase. + * registerSafariNetHandler | An instance of ISafariNetHandler. + * registerSludgeDrop | NBTTag with an ItemStack saved on it, with the weight on the "value" attribute, + * | A ValuedItem with item and value set. + * registerSpawnHandler | An instance of IMobSpawnHandler. + * registerVillagerTradeMob | An instance of IRandomMobProvider. + * + * // Simple implementations: + * { Harvestables + * registerHarvestable_Standard | The String identifier of a block. + * registerHarvestable_Log | The String identifier of a block. + * registerHarvestable_Leaves | The String identifier of a block. + * registerHarvestable_Vine | The String identifier of a block. + * registerHarvestable_Shrub | The String identifier of a block. + * registerHarvestable_Mushroom | The String identifier of a block. + * registerHarvestable_Crop | An ItemStack of a block, with a damage value indicating the meta value to harvest at. + * | A ValuedItem with value and object set; Block expected. + * registerHarvestable_Gourd | An NBTTag with the stem and fruit attributes, both String identifiers of blocks. + * } + * { Plantables + * registerPlantable_Standard | An NBTTag with the seed (Item, String identifier), and + * crop (Block, String identifier) attributes set, optionally + * also having the meta (Integer, accepted metadata value of the seed item) attribute set. + * No special checks for location, just sustainability. + * registerPlantable_Crop | An NBTTag with the seed (Item, String identifier), and + * crop (Block, String identifier) attributes set, optionally + * also having the meta (Integer, accepted metadata value of the seed item) attribute set. + * Will automatically hoe dirt and grass into farmland when planting. + * registerPlantable_Sapling | An NBTTag with the sapling (Block, String identifier), and optionally + * the seed (Item, String identifier) attributes set. + * } + * { Fertilizer + * registerFertilizer_Standard | An NBTTag with the fert (Item, String identifier), meta (Integer), and + * type (Integer, index into FertilizerType.values()) attributes set. + * } + * { Fertilizables + * registerFertilizable_Grass | The String identifier of a block. Will bonemeal the block and expect + * tall grass be planted above and around it, must be IGrowable. Works with + * the GrowPlant and Grass type fertilizers, not recommended for crop plants. + * registerFertilizable_Gourd | The String identifier of a block. Must be IGrowable, and expects identical + * behavior to vanilla stems. Works with the GrowPlant fertilizers. + * registerFertilizable_Crop | An NBTTag with the plant (Block, String identifier, IGrowable), and + * meta (Integer, max growth phase) attributes set, optionally also having + * the type (Integer, index into FertilizerType) attribute set. + * registerFertilizable_Cocoa | An NBTTag with the plant (Block, String identifier), and optionally also + * the type (Integer, index into FertilizerType) attributes set. + * Expects metadata of the block to exactly match cocoa pods. + * registerFertilizable_Standard | An NBTTag with the plant (Block, String identifier, IGrowable), and + * optionally also the type (Integer, index into FertilizerType) attributes set. + * Expects the block to change when successfully grown (e.g., saplings). + * } + */ + public static void sendMessage(String message, Object value) + { + if (!Loader.isModLoaded("MineFactoryReloaded") || + Loader.instance().activeModContainer() == null) + return; + try + { + Method m = FMLInterModComms.class.getDeclaredMethod("enqueueMessage", Object.class, String.class, IMCMessage.class); + m.setAccessible(true); + Constructor c = IMCMessage.class.getDeclaredConstructor(String.class, Object.class); + c.setAccessible(true); + m.invoke(null, Loader.instance().activeModContainer(), "MineFactoryReloaded", c.newInstance(message, value)); + } + catch(Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/FertilizerType.java b/src/main/java/powercrystals/minefactoryreloaded/api/FertilizerType.java new file mode 100644 index 000000000..43af2b656 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/FertilizerType.java @@ -0,0 +1,29 @@ +package powercrystals.minefactoryreloaded.api; + +/** + * Determines what kind of action a given fertilizer can perform. Your + * IFactoryFertilizable instances should check this before performing any action + * to maintain future compatibility. + * + * @author PowerCrystals + */ +public enum FertilizerType { + + /** + * The fertilizer will fertilize nothing. + */ + None, + /** + * The fertilizer will fertilize grass. + */ + Grass, + /** + * The fertilizer will grow a plant. + */ + GrowPlant, + /** + * The fertilizer will grow magical crops. + */ + GrowMagicalCrop, + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/HarvestType.java b/src/main/java/powercrystals/minefactoryreloaded/api/HarvestType.java new file mode 100644 index 000000000..85ef23835 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/HarvestType.java @@ -0,0 +1,56 @@ +package powercrystals.minefactoryreloaded.api; + +/** + * Determines what algorithm the Harvester uses when it encounters this + * IFactoryHarvestable in the world. + * + * @author PowerCrystals + */ +public enum HarvestType { + + /** + * Just break the single block - no special action needed. e.g. Carrots, + * flowers, wheat. + */ + Normal, + /** + * Search for harvestable blocks adjacent to this block but leave this + * block. e.g. Pumpkin, melon + */ + Gourd, + /** + * Search for identical blocks above. + */ + Column, + /** + * Search for identical blocks above but leave the bottom one for the + * future. e.g. Cactus, sugarcane. + */ + LeaveBottom, + /** + * This block is the base of a tree and the harvester should enter + * tree-cutting mode. + */ + Tree, + /** + * This block is the base of the tree and the harvester should enter + * tree-cutting mode. + * The tree is searched for in the negative y axis instead. + */ + TreeFlipped, + /** + * This block is part of a tree as above, but leaves are cut before logs. + * The tree is searched for in the current mode. + *

+ * If not in tree-cutting mode, tree-cutting mode will be entered as though + * the type was Tree. + */ + TreeLeaf, + /** + * This block is part of a tree as above, but fruits are cut before logs. + * e.g. cocoa + * The tree is not searched for. + */ + TreeFruit + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java b/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java new file mode 100644 index 000000000..2ec1f76b3 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java @@ -0,0 +1,35 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.item.ItemStack; + +public interface IDeepStorageUnit { + + /** + * @return A populated ItemStack with stackSize for the full amount of + * materials in the DSU.
+ * May have a stackSize > getMaxStackSize(). May have a stackSize of + * 0 (indicating locked contents). + */ + ItemStack getStoredItemType(); + + /** + * Sets the total amount of the item currently being stored, or zero if all + * items are to be removed. + */ + void setStoredItemCount(int amount); + + /** + * Sets the type of the stored item and initializes the number of stored + * items to amount. + *

+ * Will overwrite any existing stored items. + */ + void setStoredItemType(ItemStack type, int amount); + + /** + * @return The maximum number of items the DSU can hold.
+ * May change based on the current type stored. + */ + int getMaxStoredCount(); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizable.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizable.java new file mode 100644 index 000000000..a4b8c8975 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizable.java @@ -0,0 +1,58 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import java.util.Random; + +/** + * Defines a fertilizable block, and the process to fertilize it. You can assume + * that you will never have to check that block matches the one returned by + * getPlant(). + * + * @author PowerCrystals + */ +public interface IFactoryFertilizable { + + /** + * @return The block this instance is managing. + */ + public Block getPlant(); + + /** + * @param world + * The world this block belongs to. + * @param x + * The X coordinate of this block. + * @param y + * The Y coordinate of this block. + * @param z + * The Z coordinate of this block. + * @param fertilizerType + * The kind of fertilizer being used. + * + * @return True if the block at (x,y,z) can be fertilized with the given + * type of fertilizer. + */ + public boolean canFertilize(World world, int x, int y, int z, FertilizerType fertilizerType); + + /** + * @param world + * The world this block belongs to. + * @param rand + * A Random instance to use when fertilizing, if necessary. + * @param x + * The X coordinate of this block. + * @param y + * The Y coordinate of this block. + * @param z + * The Z coordinate of this block. + * @param fertilizerType + * The kind of fertilizer being used. + * + * @return True if fertilization was successful. If false, the Fertilizer + * will not consume a fertilizer item and will not drain power. + */ + public boolean fertilize(World world, Random rand, int x, int y, int z, FertilizerType fertilizerType); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizer.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizer.java new file mode 100644 index 000000000..2f201e68e --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizer.java @@ -0,0 +1,32 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Defines a fertilizer item for use in the Fertilizer. + * + * @author PowerCrystals + */ +public interface IFactoryFertilizer { + + /** + * @return The ID of this fertilizer item. + */ + Item getFertilizer(); + + /** + * @return The type of fertilizer this is. + */ + FertilizerType getFertilizerType(ItemStack stack); + + /** + * Called when a fertilization is successful. If you set the ItemStack size + * to 0, it will be deleted by the fertilizer. + * + * @param fertilizer + * The ItemStack used to fertilize. + */ + void consume(ItemStack fertilizer); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java new file mode 100644 index 000000000..2251ee94c --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java @@ -0,0 +1,106 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Random; + +/** + * Defines a fruit entry for the Fruit Picker. + * + * @author powercrystals + * + */ +public interface IFactoryFruit { + + /** + * @return The block this fruit has in the world. + */ + public Block getPlant(); + + /** + * Used to determine if this fruit can be picked (is it ripe yet, etc) + * + * @param world + * The world where the fruit is being picked + * @param x + * The x-coordinate of the fruit + * @param y + * The y-coordinate of the fruit + * @param z + * The z-coordinate of the fruit + * + * @return True if the fruit can be picked + */ + public boolean canBePicked(World world, int x, int y, int z); + + /** + * @deprecated This method is no longer called. ReplacementBlock now handles + * interaction. + */ + @Deprecated + public boolean breakBlock(); + + /** + * Called by the Fruit Picker to determine what block to replace the picked + * block with. At the time this method is called, the fruit still exists. + * + * @param world + * The world where the fruit is being picked + * @param x + * The x-coordinate of the fruit + * @param y + * The y-coordinate of the fruit + * @param z + * The z-coordinate of the fruit + * + * @return The block to replace the fruit block with, or null for air. + */ + public ReplacementBlock getReplacementBlock(World world, int x, int y, int z); + + /** + * Called by the Fruit Picker to determine what drops to generate. At the + * time this method is called, the fruit still exists. + * + * @param world + * The world where the fruit is being picked + * @param x + * The x-coordinate of the fruit + * @param y + * The y-coordinate of the fruit + * @param z + * The z-coordinate of the fruit + */ + public List getDrops(World world, Random rand, int x, int y, int z); + + /** + * Called by the Fruit Picker after getDrops, prior to the block being + * replaced/removed. + * + * @param world + * The world where the fruit is being picked + * @param x + * The x-coordinate of the fruit + * @param y + * The y-coordinate of the fruit + * @param z + * The z-coordinate of the fruit + */ + public void prePick(World world, int x, int y, int z); + + /** + * Called by the Fruit Picker after the fruit is picked. + * + * @param world + * The world where the fruit is being picked + * @param x + * The x-coordinate of the fruit + * @param y + * The y-coordinate of the fruit + * @param z + * The z-coordinate of the fruit + */ + public void postPick(World world, int x, int y, int z); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryGrindable.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryGrindable.java new file mode 100644 index 000000000..0ef2149fe --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryGrindable.java @@ -0,0 +1,44 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Random; + +/** + * Defines a grindable entity for the Grinder. + * + * @author PowerCrystals + */ +public interface IFactoryGrindable { + + /** + * @return The class that this grindable instance is handling. This must be + * a subtype of EntityLivingBase or the entity will never + * be noticed by the Grinder. + */ + public Class getGrindableEntity(); + + /** + * @param world + * The world this entity is in. + * @param entity + * The entity instance being ground. + * @param random + * A Random instance. + * + * @return The drops generated when this entity is killed. Only one of these + * will be chosen. + */ + public List grind(World world, EntityLivingBase entity, Random random); + + /** + * @param entity + * The entity instance being ground. + * + * @return Whether this entity has been fully processed or not. (e.g., it is + * already dead) + */ + public boolean processEntity(EntityLivingBase entity); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java new file mode 100644 index 000000000..2d691aa95 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java @@ -0,0 +1,106 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Map; +import java.util.Random; + +/** + * Defines a harvestable block for the Harvester. + * + * @author PowerCrystals + */ +public interface IFactoryHarvestable { + + /** + * @return The block this harvestable instance is managing. + */ + public Block getPlant(); + + /** + * @return The type of harvest the Harvester should perform on this block. + */ + public HarvestType getHarvestType(); + + /** + * Used to determine if the harvester should replace this block with air. + * + * @return Whether or not the Harvester should break the block when + * harvesting. If false, no changes will be performed by the + * Harvester itself. + */ + public boolean breakBlock(); + + /** + * Used to determine if this crop can be harvested (is it at a stage that + * drops crops, etc.) + * + * @param world + * The world this block is in. + * @param harvesterSettings + * The harvester's current settings. Do not modify these. + * @param x + * The X coordinate of the block being harvested. + * @param y + * The Y coordinate of the block being harvested. + * @param z + * The Z coordinate of the block being harvested. + * + * @return True if this block can be harvested. + */ + public boolean canBeHarvested(World world, Map harvesterSettings, int x, int y, int z); + + /** + * @param world + * The world this block is in. + * @param rand + * A Random instance to use when generating drops. + * @param harvesterSettings + * The harvester's current settings. Do not modify these. + * @param x + * The X coordinate of the block being harvested. + * @param y + * The Y coordinate of the block being harvested. + * @param z + * The Z coordinate of the block being harvested. + * + * @return The drops generated by breaking this block. For a default + * implementation, calling Block.getDrops() is usually + * sufficient. + */ + public List getDrops(World world, Random rand, Map harvesterSettings, int x, int y, int z); + + /** + * Called before the block is going to be harvested, after getDrops. Usually + * empty. + * + * @param world + * The world this block is in. + * @param x + * The X coordinate of the block being harvested. + * @param y + * The Y coordinate of the block being harvested. + * @param z + * The Z coordinate of the block being harvested. + */ + public void preHarvest(World world, int x, int y, int z); + + /** + * Called after the block is going to be harvested. Used to re-till soil, + * for example. + * + * @param world + * The world this block is in. + * @param x + * The X coordinate of the block being harvested. + * @param y + * The Y coordinate of the block being harvested. + * @param z + * The Z coordinate of the block being harvested. + */ + public void postHarvest(World world, int x, int y, int z); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryLaserSource.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryLaserSource.java new file mode 100644 index 000000000..4eab9eb66 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryLaserSource.java @@ -0,0 +1,24 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Defines a target for the laser blocks. TileEntities that implement this + * interface will sustain the beam. + * + * @author skyboy + */ +public interface IFactoryLaserSource { + + /** + * Used to determine if laser blocks can remain in the world when emitted + * from from + * + * @param from + * The direction the laser is oriented + * + * @return True if the beam should be sustained from this side + */ + public boolean canFormBeamFrom(ForgeDirection from); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryLaserTarget.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryLaserTarget.java new file mode 100644 index 000000000..7fcc41137 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryLaserTarget.java @@ -0,0 +1,36 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Defines a target for the Laser Drill Precharger + * + * @author skyboy + */ +public interface IFactoryLaserTarget { + + /** + * Used to be determined if a laser can be formed on from + * + * @param from + * The direction the laser is coming from + * + * @return True if the precharger can form a beam from this side + */ + public boolean canFormBeamWith(ForgeDirection from); + + /** + * Used to add energy to the tile. + * + * @param from + * The direction the energy is coming from + * @param energy + * The amount of energy being transferred + * @param simulate + * true if this transaction will only be simulated + * + * @return The amount of energy not consumed + */ + public int addEnergy(ForgeDirection from, int energy, boolean simulate); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java new file mode 100644 index 000000000..1d620b37e --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java @@ -0,0 +1,94 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +/** + * Defines a plantable object for use in the Planter. + * + * @author PowerCrystals + */ +public interface IFactoryPlantable { + + /** + * @return The item this plantable is managing. + */ + public Item getSeed(); + + /** + * @param stack + * The stack being planted. + * @param forFermenting + * True if this stack will be converted to biofuel + * + * @return True if this plantable can be planted (useful for metadata + * items). + */ + public boolean canBePlanted(ItemStack stack, boolean forFermenting); + + /** + * @param world + * The world instance this block or item will be placed into. + * @param x + * The destination X coordinate. + * @param y + * The destination Y coordinate. + * @param z + * The destination Z coordinate. + * @param stack + * The stack being planted. + * + * @return The block that will be placed into the world. + */ + public ReplacementBlock getPlantedBlock(World world, int x, int y, int z, ItemStack stack); + + /** + * @param world + * The world instance this block or item will be placed into. + * @param x + * The destination X coordinate. + * @param y + * The destination Y coordinate. + * @param z + * The destination Z coordinate. + * @param stack + * The stack being planted. + * + * @return True if this plantable can be placed at the provided coordinates. + */ + public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack); + + /** + * Called before planting is performed. Used to till soil, for example. + * + * @param world + * The world instance this block or item will be placed into. + * @param x + * The destination X coordinate. + * @param y + * The destination Y coordinate. + * @param z + * The destination Z coordinate. + * @param stack + * The stack being planted. + */ + public void prePlant(World world, int x, int y, int z, ItemStack stack); + + /** + * Called after planting is performed. Usually empty. + * + * @param world + * The world instance this block or item will be placed into. + * @param x + * The destination X coordinate. + * @param y + * The destination Y coordinate. + * @param z + * The destination Z coordinate. + * @param stack + * The stack being planted. + */ + public void postPlant(World world, int x, int y, int z, ItemStack stack); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryRanchable.java b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryRanchable.java new file mode 100644 index 000000000..21fc61abc --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IFactoryRanchable.java @@ -0,0 +1,34 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.inventory.IInventory; +import net.minecraft.world.World; + +import java.util.List; + +/** + * Defines a ranchable entity for use in the Rancher. + * + * @author PowerCrystals + */ +public interface IFactoryRanchable { + + /** + * @return The entity being ranched. Must be a subtype of EntityLivingBase. + */ + public Class getRanchableEntity(); + + /** + * @param world + * The world this entity is in. + * @param entity + * The entity instance being ranched. + * @param rancher + * The rancher instance doing the ranching. Used to access the + * Rancher's inventory when milking cows, for example. + * + * @return A list of drops. All Items be dropped, fluids not matching the tank's contents will be discarded. + */ + public List ranch(World world, EntityLivingBase entity, IInventory rancher); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/ILiquidDrinkHandler.java b/src/main/java/powercrystals/minefactoryreloaded/api/ILiquidDrinkHandler.java new file mode 100644 index 000000000..d8d58866a --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/ILiquidDrinkHandler.java @@ -0,0 +1,16 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.EntityLivingBase; + +public interface ILiquidDrinkHandler { + + /** + * Called when an entity has consumed the fluid this manages. + * + * @param entity + * The entity that has consumed the fluid this + * ILiquidDrinkHandler manages + */ + public void onDrink(EntityLivingBase entity); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IMFRHammer.java b/src/main/java/powercrystals/minefactoryreloaded/api/IMFRHammer.java new file mode 100644 index 000000000..4f951dae0 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IMFRHammer.java @@ -0,0 +1,11 @@ +package powercrystals.minefactoryreloaded.api; + +/** + * Defines a tool that can rotate MFR machines. Implement on an Item class. + * Requires no additional work on your part. + * + * @author PowerCrystals + */ +public interface IMFRHammer { + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IMobEggHandler.java b/src/main/java/powercrystals/minefactoryreloaded/api/IMobEggHandler.java new file mode 100644 index 000000000..4801feb9f --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IMobEggHandler.java @@ -0,0 +1,23 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.EntityList.EntityEggInfo; +import net.minecraft.item.ItemStack; + +/** + * Defines a class that MFR will use to local egg info for a given mob. This is + * used to color the Safari Net based on the captured mob. + * + * @author PowerCrystals + */ +public interface IMobEggHandler { + + /** + * @param safariNet + * The Safari Net that is looking for egg info. + * + * @return An EntityEggInfo, or null if this instance cannot handle this + * mob. + */ + public EntityEggInfo getEgg(ItemStack safariNet); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IMobSpawnHandler.java b/src/main/java/powercrystals/minefactoryreloaded/api/IMobSpawnHandler.java new file mode 100644 index 000000000..65d2b3031 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IMobSpawnHandler.java @@ -0,0 +1,35 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.EntityLivingBase; + +/** + * Defines a handler for mob spawns from the autospawner. Added primarily to + * solve item duping on exact spawn & entity inventories + * + * @author skyboy + */ +public interface IMobSpawnHandler { + + /** + * @return The class that this instance is handling. + */ + public Class getMobClass(); + + /** + * Called when a mob has been spawned normally. + * + * @param entity + * The entity instance being spawned. Typically your regular + * spawn code 100% handles this + */ + public void onMobSpawn(EntityLivingBase entity); + + /** + * Called when an exact copy of an entity has been made. + * + * @param entity + * The entity instance being exact-copied. Clear your inventories + * & etc. here + */ + public void onMobExactSpawn(EntityLivingBase entity); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/INeedleAmmo.java b/src/main/java/powercrystals/minefactoryreloaded/api/INeedleAmmo.java new file mode 100644 index 000000000..38e648205 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/INeedleAmmo.java @@ -0,0 +1,16 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface INeedleAmmo { + + public boolean onHitEntity(ItemStack stac, EntityPlayer owner, Entity hit, double distance); + + public void onHitBlock(ItemStack stac, EntityPlayer owner, World world, int x, int y, int z, int side, double distance); + + public float getSpread(ItemStack stack); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IRandomMobProvider.java b/src/main/java/powercrystals/minefactoryreloaded/api/IRandomMobProvider.java new file mode 100644 index 000000000..e72db202c --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IRandomMobProvider.java @@ -0,0 +1,19 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.world.World; + +import java.util.List; + +public interface IRandomMobProvider { + + /** + * Called to provide random entities to be spawned by mystery SafariNets + * + * @param world + * The world object the entities will be spawned in. + * @return A list of RandomMob instances of entities that are all ready to + * be spawned in the world with no additional method calls. + */ + public List getRandomMobs(World world); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/ISafariNetHandler.java b/src/main/java/powercrystals/minefactoryreloaded/api/ISafariNetHandler.java new file mode 100644 index 000000000..cb9a0d7ff --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/ISafariNetHandler.java @@ -0,0 +1,35 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Defines an object that can display information about a captured mob in a + * Safari net. + * + * @author PowerCrystals + */ +public interface ISafariNetHandler { + + /** + * @return The class of mob that this handler applies to. + */ + public Class validFor(); + + /** + * Called to add information regarding a mob contained in a SafariNet. + * + * @param safariNetStack + * The Safari Net that is requesting information. + * @param player + * The player holding the Safari Net. + * @param infoList + * The current list of information strings. Add yours to this. + * @param advancedTooltips + * True if the advanced tooltips option is on. + */ + public void addInformation(ItemStack safariNetStack, EntityPlayer player, List infoList, boolean advancedTooltips); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/ISyringe.java b/src/main/java/powercrystals/minefactoryreloaded/api/ISyringe.java new file mode 100644 index 000000000..b3cbfba9d --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/ISyringe.java @@ -0,0 +1,64 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +/** + * Defines a syringe for use in the Vet machine. + * + * @author PowerCrystals + */ +public interface ISyringe { + + /** + * Called when the vet is deciding if it should use this syringe. + * + * @param world + * The world instance. + * @param entity + * The entity being injected. + * @param syringe + * The syringe ItemStack. + * + * @return True if the entity can be injected by this syringe. + */ + public boolean canInject(World world, EntityLivingBase entity, ItemStack syringe); + + /** + * Called to perform an injection. + * + * @param world + * The world instance. + * @param entity + * The entity being injected. + * @param syringe + * The syringe ItemStack. + * + * @return True if injection was successful. + */ + public boolean inject(World world, EntityLivingBase entity, ItemStack syringe); + + /** + * Called to check if a syringe is empty + * + * @param syringe + * The syringe ItemStack. + * + * @return True if the syringe is empty + */ + public boolean isEmpty(ItemStack syringe); + + /** + * Called to get the empty syringe + *

+ * Note: this will replace the syringe, max stacksize should be 1 + * + * @param syringe + * The syringe ItemStack. + * + * @return An empty syringe ItemStack + */ + public ItemStack getEmptySyringe(ItemStack syringe); + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/MobDrop.java b/src/main/java/powercrystals/minefactoryreloaded/api/MobDrop.java new file mode 100644 index 000000000..7f5dd7cc9 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/MobDrop.java @@ -0,0 +1,21 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; + +public class MobDrop extends WeightedRandom.Item +{ + private ItemStack _stack; + + public MobDrop(int weight, ItemStack stack) + { + super(weight); + _stack = stack; + } + + public ItemStack getStack() + { + if(_stack == null) return null; + return _stack.copy(); + } +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/RanchedItem.java b/src/main/java/powercrystals/minefactoryreloaded/api/RanchedItem.java new file mode 100644 index 000000000..86791cc54 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/RanchedItem.java @@ -0,0 +1,68 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +/** + * @author skyboy026 + * + * Defines an ItemStack or a FluidStack that is the result of an entity being ranched + */ +public final class RanchedItem { + private final ItemStack item; + private final FluidStack fluid; + + public RanchedItem(Block item, int amount, int meta) + { + this(new ItemStack(item, amount, meta)); + } + + public RanchedItem(Block item, int amount) + { + this(new ItemStack(item, amount)); + } + + public RanchedItem(Block item) + { + this(new ItemStack(item)); + } + + public RanchedItem(Item item, int amount, int meta) + { + this(new ItemStack(item, amount, meta)); + } + + public RanchedItem(Item item, int amount) + { + this(new ItemStack(item, amount)); + } + + public RanchedItem(Item item) + { + this(new ItemStack(item)); + } + + public RanchedItem(ItemStack item) + { + this.item = item; + fluid = null; + } + + public RanchedItem(FluidStack fluid) + { + this.fluid = fluid; + item = null; + } + + public boolean hasFluid() + { + return item == null & fluid != null; + } + + public Object getResult() + { + return item == null ? fluid : item; + } +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/RandomMob.java b/src/main/java/powercrystals/minefactoryreloaded/api/RandomMob.java new file mode 100644 index 000000000..2ffa56b1a --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/RandomMob.java @@ -0,0 +1,28 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.entity.Entity; +import net.minecraft.util.WeightedRandom; + +public class RandomMob extends WeightedRandom.Item +{ + private Entity _mob; + public final boolean shouldInit; + + public RandomMob(Entity savedMob, int weight, boolean init) + { + super(weight); + _mob = savedMob; + shouldInit = init; + } + + public RandomMob(Entity savedMob, int weight) + { + this(savedMob, weight, true); + } + + public Entity getMob() + { + if(_mob == null) return null; + return _mob; + } +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java b/src/main/java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java new file mode 100644 index 000000000..88cd7a86f --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java @@ -0,0 +1,137 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class ReplacementBlock +{ + protected byte _hasMeta; + protected int _meta; + protected final Block _block; + protected final NBTTagCompound _tileTag; + + /** + * Called to replace a block in the world. + * @param world The world object + * @param x The X coord + * @param y The Y coord + * @param z The Z coord + * @param stack The ItemStack being used to replace the block (may be null) + * @return True if the block was set successfully + */ + public boolean replaceBlock(World world, int x, int y, int z, ItemStack stack) + { + int meta = getMeta(world, x, y, z, stack); + if (world.setBlock(x, y, z, _block, meta, 3)) + { + if (hasTag(stack) && _block.hasTileEntity(meta)) + { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null) + tile.readFromNBT(getTag(world, x, y, z, stack)); + } + return true; + } + return false; + } + + /** + * Called to get the metadata of the replacement block in the world. + * @param world The world object + * @param x The X coord + * @param y The Y coord + * @param z The Z coord + * @param stack The ItemStack being used to replace the block (may be null) + * @return The metadata of the block + */ + protected int getMeta(World world, int x, int y, int z, ItemStack stack) + { + int m = 0; + if (_hasMeta > 0) + { + if (_hasMeta > 1) + return _meta; + m = stack.getItemDamage(); + Item item = stack.getItem(); + if (item instanceof ItemBlock) + m = ((ItemBlock)item).getMetadata(m); + } + return m; + } + + /** + * Called to set the metdata of this ReplacementBlock to a fixed value + * @param meta The metadata of the block + * @return This instance + */ + public ReplacementBlock setMeta(int meta) + { + if (meta >= 0) + { + _hasMeta = 2; + _meta = meta; + } + return this; + } + + /** + * Called to set the metdata of this ReplacementBlock to a value read from an ItemStack + * @param meta The metadata of the block + * @return This instance + */ + public ReplacementBlock setMeta(boolean hasMeta) + { + _hasMeta = (byte) (hasMeta ? 1 : 0); + return this; + } + + /** + * Called to get the NBTTagCompound a TileEntity will read its state from + * @param world The world object + * @param x The X coord + * @param y The Y coord + * @param z The Z coord + * @param stack The ItemStack being used to replace the block (may be null) + * @return The NBTTagCompound a TileEntity will read its state from + */ + protected NBTTagCompound getTag(World world, int x, int y, int z, ItemStack stack) + { + return _tileTag; + } + + /** + * Called to see if a TileEntity should have its state set + * @param stack The ItemStack being used to replace the block (may be null) + * @return True if the TileEntity should have its state set + */ + protected boolean hasTag(ItemStack stack) + { + return _tileTag != null; + } + + public ReplacementBlock(Item block) + { + this(Block.getBlockFromItem(block)); + } + + public ReplacementBlock(Item block, NBTTagCompound tag) + { + this(Block.getBlockFromItem(block), tag); + } + + public ReplacementBlock(Block block) + { + this(block, null); + } + + public ReplacementBlock(Block block, NBTTagCompound tag) + { + _block = block; + _tileTag = tag; + } +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/ValuedItem.java b/src/main/java/powercrystals/minefactoryreloaded/api/ValuedItem.java new file mode 100644 index 000000000..3d075fa3b --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/ValuedItem.java @@ -0,0 +1,72 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.item.ItemStack; + +public class ValuedItem +{ + public final int value; + public final ItemStack item; + public final String key; + public final Object object; + + public ValuedItem(int v, ItemStack i) + { + value = v; + item = i; + key = null; + object = null; + } + + public ValuedItem(String v, Object i) + { + value = -1; + item = null; + key = v; + object = i; + } + + /** + * Presently unused but included so that if they do get used in the future, + * people including this in their jar and loading before MFR don't destroy everyone + */ + + public ValuedItem(int v, Object i) + { + value = v; + item = null; + key = null; + object = i; + } + + public ValuedItem(String v, ItemStack i) + { + value = -1; + item = i; + key = v; + object = null; + } + + public ValuedItem(int v, String k, ItemStack i) + { + value = v; + item = i; + key = k; + object = null; + } + + public ValuedItem(int v, String k, Object i) + { + value = v; + item = null; + key = k; + object = i; + } + + public ValuedItem(int v, String k, ItemStack i, Object o) + { + value = v; + item = i; + key = k; + object = o; + } +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInfo.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInfo.java new file mode 100644 index 000000000..b6b8a23df --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInfo.java @@ -0,0 +1,28 @@ +package powercrystals.minefactoryreloaded.api.rednet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.List; + +/** + * Defines a Block that can print information about itself using the RedNet Meter. This must be implemented on your Block class. + */ +public interface IRedNetInfo +{ + /** + * This function appends information to a list provided to it. + * + * @param world Reference to the world. + * @param x X coordinate of the block. + * @param y Y coordinate of the block. + * @param z Z coordinate of the block. + * @param side The side of the block that is being queried. + * @param player Player doing the querying - this can be NULL. + * @param info The list that the information should be appended to. + */ + public void getRedNetInfo(IBlockAccess world, int x, int y, int z, + ForgeDirection side, EntityPlayer player, List info); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInputNode.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInputNode.java new file mode 100644 index 000000000..a0f8b7094 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInputNode.java @@ -0,0 +1,51 @@ +package powercrystals.minefactoryreloaded.api.rednet; + +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection; + +/** + * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. + *

+ * Note that when you implement this, the RedNet network makes several assumptions about your code - + * It will not clamp values to 0 <= x <= 15. This means you must be able to accept any possible integer + * without crashing, even negatives. It will also assume that calling the onInput(s)Changed() methods + * are sufficient, and will not issue block updates. In Single mode, it will call onInputChanged. + *

+ * RedNet cables have their subnets indicated to the user by colored bands on the cable. + * The color of a given subnet is the same as the wool with metadata equal to the subnet number. + *

+ * For reference:
+ * 0:White, 1:Orange, 2:Magenta, 3:LightBlue, 4:Yellow, 5:Lime, 6:Pink, 7:Gray, + * 8:LightGray, 9:Cyan, 10:Purple, 11:Blue, 12:Brown, 13:Green, 14:Red, 15:Black + */ +public interface IRedNetInputNode extends IRedNetConnection +{ + /** + * Called when the input values to this block change. Only called if your block is connected in "All" mode. + * Do not issue a network value update from inside this method call; it will be ignored. Issue your updates + * on the next tick. + * + * @param world The world this block is in. + * @param x This block's X coordinate. + * @param y This block's Y coordinate. + * @param z This block's Z coordinate. + * @param side The side the input values are being changed on. + * @param inputValues The new set of input values. This array will be 16 elements long. Do not alter or cache. + */ + public void onInputsChanged(World world, int x, int y, int z, ForgeDirection side, int[] inputValues); + + /** + * Called when the input value to this block changes. Only called if your block is connected in "Single" mode. + * Do not issue a network value update from inside this method call; it will be ignored. Issue your updates + * on the next tick. + * + * @param world The world this block is in. + * @param x This block's X coordinate. + * @param y This block's Y coordinate. + * @param z This block's Z coordinate. + * @param side The side the input values are being changed on. + * @param inputValue The new input value + */ + public void onInputChanged(World world, int x, int y, int z, ForgeDirection side, int inputValue); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicCircuit.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicCircuit.java new file mode 100644 index 000000000..981ce06b6 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicCircuit.java @@ -0,0 +1,19 @@ +package powercrystals.minefactoryreloaded.api.rednet; + +import net.minecraft.nbt.NBTTagCompound; + +public interface IRedNetLogicCircuit +{ + public byte getInputCount(); + + public byte getOutputCount(); + + public int[] recalculateOutputValues(long worldTime, int[] inputValues); + + public String getUnlocalizedName(); + public String getInputPinLabel(int pin); + public String getOutputPinLabel(int pin); + + public void readFromNBT(NBTTagCompound tag); + public void writeToNBT(NBTTagCompound tag); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicPoint.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicPoint.java new file mode 100644 index 000000000..dd05969e9 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicPoint.java @@ -0,0 +1,36 @@ +package powercrystals.minefactoryreloaded.api.rednet; + +/** + * + * @author skyboy + */ +public interface IRedNetLogicPoint +{ + /** + * + * @param out + * @return + */ + public void transformOutput(int[] out); + + /** + * + * @param out + * @return + */ + public void transformOutput(int out); + + /** + * + * @param in + * @return + */ + public int[] transformInput(int[] in); + + /** + * + * @param in + * @return + */ + public int transformInput(int in); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetNetworkContainer.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetNetworkContainer.java new file mode 100644 index 000000000..c9fb0bf81 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetNetworkContainer.java @@ -0,0 +1,32 @@ +package powercrystals.minefactoryreloaded.api.rednet; + +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * + * You should not implement this yourself. Instead, use this to look for cables to notify from your IRedNetOmniNode as this does not + * require a block update. This will be implemented on the cable's Block class. + * + */ +public interface IRedNetNetworkContainer +{ + /** + * Tells the network to recalculate all subnets. + * @param world The world this cable is in. + * @param x The x-coordinate of this cable. + * @param x The y-coordinate of this cable. + * @param x The z-coordinate of this cable. + */ + public void updateNetwork(World world, int x, int y, int z, ForgeDirection from); + + /** + * Tells the network to recalculate a specific subnet. + * @param world The world this cable is in. + * @param x The x-coordinate of this cable. + * @param x The y-coordinate of this cable. + * @param x The z-coordinate of this cable. + * @param subnet The subnet to recalculate. + */ + public void updateNetwork(World world, int x, int y, int z, int subnet, ForgeDirection from); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOmniNode.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOmniNode.java new file mode 100644 index 000000000..f2bdf397c --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOmniNode.java @@ -0,0 +1,22 @@ +package powercrystals.minefactoryreloaded.api.rednet; + +/** + * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. + *

+ * Note that when you implement this, the RedNet network makes several assumptions about your code - + * It will not clamp values to 0 <= x <= 15. This means you must be able to accept any possible integer + * without crashing, even negatives. It will also assume that calling the onInput(s)Changed() methods + * are sufficient, and will not issue block updates. It will never call the vanilla redstone output + * methods, and will only query the methods contained in this interface. + *

+ * RedNet cables have their subnets indicated to the user by colored bands on the cable. + * The color of a given subnet is the same as the wool with metadata equal to the subnet number. + *

+ * For reference:
+ * 0:White, 1:Orange, 2:Magenta, 3:LightBlue, 4:Yellow, 5:Lime, 6:Pink, 7:Gray, + * 8:LightGray, 9:Cyan, 10:Purple, 11:Blue, 12:Brown, 13:Green, 14:Red, 15:Black + */ +public interface IRedNetOmniNode extends IRedNetInputNode, IRedNetOutputNode +{ + // this is merely provided for convenience +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOutputNode.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOutputNode.java new file mode 100644 index 000000000..8a0b41568 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOutputNode.java @@ -0,0 +1,50 @@ +package powercrystals.minefactoryreloaded.api.rednet; + +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection; + +/** + * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. + *

+ * Note that when you implement this, the RedNet network makes several assumptions about your code - + * It will never call the vanilla redstone output methods, querying only the methods contained in + * this interface, and will not issue block updates. + *

+ * RedNet cables have their subnets indicated to the user by colored bands on the cable. + * The color of a given subnet is the same as the wool with metadata equal to the subnet number. + *

+ * For reference:
+ * 0:White, 1:Orange, 2:Magenta, 3:LightBlue, 4:Yellow, 5:Lime, 6:Pink, 7:Gray, + * 8:LightGray, 9:Cyan, 10:Purple, 11:Blue, 12:Brown, 13:Green, 14:Red, 15:Black + */ +public interface IRedNetOutputNode extends IRedNetConnection +{ + /** + * Returns the output values of this RedNet node. + * This array must be 16 elements long. + * Only called if your block is connected in "All" mode. + * + * @param world The world this block is in. + * @param x This block's X coordinate. + * @param y This block's Y coordinate. + * @param z This block's Z coordinate. + * @param side The side the output values are required for. + * @return The output values. + */ + public int[] getOutputValues(World world, int x, int y, int z, ForgeDirection side); + + /** + * Returns the output value of this RedNet node for a given subnet. + * Must be the same as getOutputValues(world, x, y, z, side)[subnet]. + * + * @param world The world this block is in. + * @param x This block's X coordinate. + * @param y This block's Y coordinate. + * @param z This block's Z coordinate. + * @param side The side the output value is required for. + * @param subnet The subnet to get the output value for (0-15). + * @return The output value. + */ + public int getOutputValue(World world, int x, int y, int z, ForgeDirection side, int subnet); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetConnection.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetConnection.java new file mode 100644 index 000000000..003800d8f --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetConnection.java @@ -0,0 +1,26 @@ +package powercrystals.minefactoryreloaded.api.rednet.connectivity; + +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. + */ +public interface IRedNetConnection +{ + /** + * Returns the connection type of this Block. If this value must be changed + * while the block is alive, it must notify neighbors of a change. + *

+ * For nodes that want to interact with rednet, + * see IRedNetInputNode, IRedNetOutputNode, and IRedNetOmniNode + * + * @param world The world this block is in. + * @param x This block's X coordinate. + * @param y This block's Y coordinate. + * @param z This block's Z coordinate. + * @param side The side that connection information is required for. + * @return The connection type. + */ + public RedNetConnectionType getConnectionType(World world, int x, int y, int z, ForgeDirection side); +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetDecorative.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetDecorative.java new file mode 100644 index 000000000..89de12b13 --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetDecorative.java @@ -0,0 +1,11 @@ +package powercrystals.minefactoryreloaded.api.rednet.connectivity; + +/** + * This must be implemented on your Block class. + *

+ * RedNet cables will treat your block similar to a vanilla block that's not redstone active. + */ +public interface IRedNetDecorative +{ + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetNoConnection.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetNoConnection.java new file mode 100644 index 000000000..16225a74f --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetNoConnection.java @@ -0,0 +1,13 @@ +package powercrystals.minefactoryreloaded.api.rednet.connectivity; + +/** + * This must be implemented on your Block class. + *

+ * RedNet cables will not connect to your block. + *
+ * This behavior can be overridden in subclasses by IRedNetConnection + */ +public interface IRedNetNoConnection +{ + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedstoneAlike.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedstoneAlike.java new file mode 100644 index 000000000..f3784cfbf --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedstoneAlike.java @@ -0,0 +1,10 @@ +package powercrystals.minefactoryreloaded.api.rednet.connectivity; + +/** + * This must be implemented on your Block class. + *

+ * RedNet cables will treat your block similar to a redstone dust, and subtract one from the power value. + */ +public interface IRedstoneAlike { + +} diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/RedNetConnectionType.java b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/RedNetConnectionType.java new file mode 100644 index 000000000..08ba24c1e --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/RedNetConnectionType.java @@ -0,0 +1,86 @@ +package powercrystals.minefactoryreloaded.api.rednet.connectivity; + +import java.util.HashMap; +import java.util.Map; + +/** + * Defines how RedNet cable connects to a block + *

+ * None: RedNet will never connect to this block (if this is all you want: use IRedNetNoConnection) + *

+ * CableSingle: Connections will use the cable renderer with a single band, best used for whole blocks + *
+ * PlateSingle: Connections will use the plate renderer with a single band, used for conveyers and rails + *

+ * CableAll: Connections permit access to all 16 bands + *
+ * PlateAll: Connections permit access to all 16 bands + *

+ * Forced connection modes are best used for decoration blocks: RedNet will not connect normally, + * but will if the user forces it. Typically, IRedNetDecorative is desired for this instead + *

+ * ForcedCableSingle: Connections permit access to a single band, only when the cable is in forced connection mode + *
+ * ForcedPlateSingle: Connections permit access to a single band, only when the cable is in forced connection mode + *

+ * ForcedCableAll: Connections permit access to all 16 bands, only when the cable is in forced connection mode + *
+ * ForcedPlateAll: Connections permit access to all 16 bands, only when the cable is in forced connection mode + *

+ * The decorative nodes are for when you want rednet to decide how to connect to your block, + * but also need to receive full updates from the network. + *

+ * DecorativeSingle: Connections permit access to a single band, using standard connection logic + *
+ * DecorativeAll: Connections permit access to all 16 bands, using standard connection logic + *
+ * ForcedDecorativeSingle: Connections permit access to a single band, only when the cable is in forced connection mode + *
+ * ForcedDecorativeAll: Connections permit access to all 16 bands, only when the cable is in forced connection mode + */ +public enum RedNetConnectionType +{ + None, // 0; 0000000 + CableSingle, // 11; 0001011 + PlateSingle, // 13; 0001101 + CableAll, // 19; 0010011 + PlateAll, // 21; 0010101 + ForcedCableSingle, // 43; 0101011 + ForcedPlateSingle, // 45; 0101101 + ForcedCableAll, // 51; 0110011 + ForcedPlateAll, // 53; 0110101 + DecorativeSingle, // NA; 0001001 + DecorativeAll, // NA; 0010001 + ForcedDecorativeSingle, // NA; 0101001 + ForcedDecorativeAll; // NA; 0110001 + + public final boolean isConnected = this.ordinal() != 0; // 0 bit (mask: 1) + public final boolean isSingleSubnet = this.name().endsWith("Single"); // 3 bit (mask: 8) + public final boolean isAllSubnets = this.name().endsWith("All"); // 4 bit (mask: 16) + public final boolean isPlate = this.name().contains("Plate"); // 2 bit (mask: 4) + public final boolean isCable = this.name().contains("Cable"); // 1 bit (mask: 2) + public final boolean isConnectionForced = this.name().startsWith("Forced"); // 5 bit (mask: 32) + public final boolean isDecorative = this.name().contains("Decorative"); + public final short flags = toFlags(isConnected, isCable, isPlate, + isSingleSubnet, isAllSubnets, isConnectionForced); + + public static final RedNetConnectionType fromFlags(short flags) + { + return connections.get(flags); + } + + private static final short toFlags(boolean ...flags) + { + short ret = 0; + for (int i = flags.length; i --> 0;) + ret |= (flags[i] ? 1 : 0) << i; + return ret; + } + + private static final Map connections = new HashMap(); + + static { + for (RedNetConnectionType type : RedNetConnectionType.values()) + connections.put(type.flags, type); + } +} diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 825a39cef..770a179ed 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -57,7 +57,7 @@ tooltip.actuallyadditions.blockPhantomface.desc.2=Input things into me to input item.actuallyadditions.itemPhantomConnector.name=Phantom Connector tooltip.actuallyadditions.itemPhantomConnector.desc.1=Connects a Phantom Face to any Inventory Block! -tooltip.actuallyadditions.itemPhantomConnector.desc.2=Press Control to clear the stored TileEntity +tooltip.actuallyadditions.itemPhantomConnector.desc.2=Hold ALT to clear the stored TileEntity item.actuallyadditions.itemCanolaSeed.name=Canola Seeds tooltip.actuallyadditions.itemCanolaSeed.desc=Grows on Grass!