Removed Farm
This commit is contained in:
parent
97d990e316
commit
081f16a533
17 changed files with 1 additions and 946 deletions
|
@ -1,9 +0,0 @@
|
|||
package techreborn.api.farm;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IFarmLogicContainer {
|
||||
|
||||
public IFarmLogicDevice getLogicFromStack(ItemStack stack);
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package techreborn.api.farm;
|
||||
|
||||
import techreborn.tiles.TileFarm;
|
||||
|
||||
public interface IFarmLogicDevice {
|
||||
|
||||
public void tick(TileFarm tileFarm);
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.farm;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.TileFarm;
|
||||
|
||||
public class BlockFarm extends BlockMachineBase {
|
||||
public BlockFarm() {
|
||||
super(Material.iron);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setBlockName("techreborn.farm");
|
||||
setHardness(2F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileFarm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if (!player.isSneaking()) {
|
||||
player.openGui(Core.INSTANCE, GuiHandler.farmID, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -125,8 +125,6 @@ public class GuiHandler implements IGuiHandler {
|
|||
return new ContainerIDSU((TileIDSU) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == chargeBench) {
|
||||
return new ContainerChargeBench((TileChargeBench) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == farmID) {
|
||||
return new ContainerFarm((TileFarm) world.getTileEntity(x, y, z), player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,8 +213,6 @@ public class GuiHandler implements IGuiHandler {
|
|||
return new GuiIDSU(player, (TileIDSU) world.getTileEntity(x, y, z));
|
||||
} else if (ID == chargeBench) {
|
||||
return new GuiChargeBench(player, (TileChargeBench) world.getTileEntity(x, y, z));
|
||||
} else if (ID == farmID) {
|
||||
return new GuiFarm(new ContainerFarm((TileFarm) world.getTileEntity(x, y, z), player));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.tiles.TileFarm;
|
||||
|
||||
public class ContainerFarm extends TechRebornContainer {
|
||||
|
||||
TileFarm farm;
|
||||
EntityPlayer player;
|
||||
|
||||
public ContainerFarm(TileFarm farm, EntityPlayer player) {
|
||||
this.farm = farm;
|
||||
this.player = player;
|
||||
|
||||
|
||||
this.addSlotToContainer(new Slot(farm.inventory, 0, 35, 7));
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
this.addSlotToContainer(new Slot(farm.inventory, 1 + i, 71 + (i * 18), 52));
|
||||
}
|
||||
|
||||
|
||||
int p = 5;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new Slot(farm.inventory, p, 143 + (i * 18), 16 + (j * 18)));
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18 + 27, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18 + 27,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import techreborn.client.container.ContainerFarm;
|
||||
|
||||
public class GuiFarm extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(
|
||||
"techreborn", "textures/gui/farm.png");
|
||||
|
||||
ContainerFarm containerFarm;
|
||||
|
||||
public GuiFarm(ContainerFarm container) {
|
||||
super(container);
|
||||
this.xSize = 203;
|
||||
this.ySize = 166;
|
||||
container = (ContainerFarm) this.inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int arg0, int arg1) {
|
||||
String name = StatCollector.translateToLocal("tile.techreborn.farm.name");
|
||||
fontRendererObj.drawString(name, xSize / 2 - fontRendererObj.getStringWidth(name) / 2 + 68, 5, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 60,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
super.drawGuiContainerForegroundLayer(arg0, arg1);
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package techreborn.client.render;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.lib.Functions;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.parts.FarmInventoryCable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class RenderFarmInventoryCable {
|
||||
|
||||
|
||||
public static void renderBox(Vecs3dCube cube, Block block, Tessellator tessellator, RenderBlocks renderblocks, IIcon texture, Double xD, Double yD, double zD, float thickness) {
|
||||
block.setBlockBounds((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ(), (float) cube.getMaxX() + thickness, (float) cube.getMaxY() + thickness, (float) cube.getMaxZ() + thickness);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
|
||||
renderblocks.renderFaceYNeg(block, xD, yD, zD, texture);
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
renderblocks.renderFaceYPos(block, xD, yD, zD, texture);
|
||||
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
|
||||
renderblocks.renderFaceZNeg(block, xD, yD, zD, texture);
|
||||
renderblocks.renderFaceZPos(block, xD, yD, zD, texture);
|
||||
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
|
||||
renderblocks.renderFaceXNeg(block, xD, yD, zD, texture);
|
||||
renderblocks.renderFaceXPos(block, xD, yD, zD, texture);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean renderStatic(Vecs3d translation, int pass, FarmInventoryCable part) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon stone = Blocks.stone.getIcon(0, 0);
|
||||
IIcon redstone = Blocks.redstone_block.getIcon(0, 0);
|
||||
IIcon quartz = Blocks.quartz_block.getIcon(0, 0);
|
||||
RenderBlocks renderblocks = RenderBlocks.getInstance();
|
||||
double xD = part.xCoord;
|
||||
double yD = part.yCoord;
|
||||
double zD = part.zCoord;
|
||||
Block block = part.getBlockType();
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(part.getWorld(), part.getX(), part.getY(), part.getZ()));
|
||||
Vecs3dCube cube = new Vecs3dCube(part.boundingBoxes[6].getMinX() + 0.1, part.boundingBoxes[6].getMinY() + 0.1, part.boundingBoxes[6].getMinZ() + 0.1, part.boundingBoxes[6].getMaxX() - 0.1, part.boundingBoxes[6].getMaxY() - 0.1, part.boundingBoxes[6].getMaxZ() - 0.1);
|
||||
renderBox(cube, block, tessellator, renderblocks, stone, xD, yD, zD, 0F);
|
||||
|
||||
ArrayList<Vecs3dCube> cubes = new ArrayList<Vecs3dCube>();
|
||||
|
||||
cube = new Vecs3dCube(0.15, 0.15, 0.15, 0.3, 0.3, 0.85);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.15, 0.15, 0.15, 0.85, 0.3, 0.3);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.15, 0.15, 0.15, 0.3, 0.85, 0.3);
|
||||
renderBox(cube, block, tessellator, renderblocks, redstone, xD, yD, zD, 0F);
|
||||
|
||||
cube = new Vecs3dCube(0.85, 0.85, 0.85, 0.7, 0.15, 0.7);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.85, 0.85, 0.85, 0.7, 0.7, 0.15);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.85, 0.85, 0.85, 0.15, 0.7, 0.7);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.15, 0.85, 0.85, 0.3, 0.15, 0.7);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.85, 0.85, 0.15, 0.7, 0.15, 0.3);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.85, 0.15, 0.85, 0.7, 0.3, 0.15);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.85, 0.15, 0.85, 0.15, 0.3, 0.7);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.15, 0.85, 0.15, 0.85, 0.7, 0.3);
|
||||
cubes.add(cube);
|
||||
|
||||
cube = new Vecs3dCube(0.15, 0.85, 0.15, 0.3, 0.7, 0.85);
|
||||
cubes.add(cube);
|
||||
|
||||
for (Vecs3dCube vecs3dCube : cubes) {
|
||||
renderBox(vecs3dCube, block, tessellator, renderblocks, redstone, xD, yD, zD, 0f);
|
||||
}
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.values()) {
|
||||
if (part.connectedSides.get(direction) != null) {
|
||||
renderBox(part.boundingBoxes[Functions.getIntDirFromDirection(direction)], block, tessellator, renderblocks, quartz, xD, yD, zD, 0f);
|
||||
}
|
||||
}
|
||||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,258 +0,0 @@
|
|||
package techreborn.farm;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import techreborn.api.farm.IFarmLogicDevice;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.tiles.TileFarm;
|
||||
import techreborn.util.ItemUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FarmTree implements IFarmLogicDevice {
|
||||
|
||||
public static ArrayList<Block> harvestableLogs = new ArrayList<Block>();
|
||||
ArrayList<Location> farmlandToPlace = new ArrayList<Location>();
|
||||
Block farmlandType = Blocks.dirt;
|
||||
int harvestx = 0;
|
||||
int harvesty = 0;
|
||||
int harvestz = 0;
|
||||
boolean isHavrvesting = false;
|
||||
|
||||
protected static EntityPlayer fakePlayer = null;
|
||||
public static GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("BlameMJ".getBytes()), "BlameMJ");
|
||||
|
||||
@Override
|
||||
public void tick(TileFarm tileFarm) {
|
||||
if (tileFarm.getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
if (tileFarm.canUseEnergy(ConfigTechReborn.farmEu)) {
|
||||
tileFarm.useEnergy(ConfigTechReborn.farmEu);
|
||||
if (tileFarm.getWorldObj().getTotalWorldTime() % 20 == 0 || tileFarm.inventory.hasChanged) {
|
||||
calculateFarmLand(tileFarm);
|
||||
}
|
||||
if (tileFarm.getWorldObj().getTotalWorldTime() % 10 == 0) {
|
||||
farmLandTick(tileFarm);
|
||||
saplinTick(tileFarm);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
harvestTick(tileFarm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateFarmLand(TileFarm tileFarm) {
|
||||
if (farmlandToPlace.isEmpty()) {
|
||||
for (int x = -tileFarm.size + 1; x < tileFarm.size; x++) {
|
||||
for (int z = -tileFarm.size + 1; z < tileFarm.size; z++) {
|
||||
int xpos = x + tileFarm.xCoord;
|
||||
int ypos = tileFarm.yCoord + 1;
|
||||
int zpos = z + tileFarm.zCoord;
|
||||
if (tileFarm.getWorldObj().getBlock(xpos, ypos, zpos) != farmlandType) {
|
||||
farmlandToPlace.add(new Location(xpos, ypos, zpos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void farmLandTick(TileFarm tileFarm) {
|
||||
if (!farmlandToPlace.isEmpty()) {
|
||||
Location location = farmlandToPlace.get(0);
|
||||
if (tileFarm.getWorldObj().getBlock(location.getX(), location.getY(), location.getZ()) != farmlandType) {
|
||||
if (removeInputStack(new ItemStack(Blocks.dirt), tileFarm)) {
|
||||
tileFarm.getWorldObj().setBlock(location.getX(), location.getY(), location.getZ(), farmlandType);
|
||||
}
|
||||
}
|
||||
farmlandToPlace.remove(location);
|
||||
}
|
||||
}
|
||||
|
||||
int sapx = 0;
|
||||
int sapz = 0;
|
||||
boolean isplanting;
|
||||
|
||||
public void saplinTick(TileFarm tileFarm) {
|
||||
if (!isplanting) {
|
||||
sapx = -tileFarm.size;
|
||||
sapz = -tileFarm.size;
|
||||
isplanting = true;
|
||||
} else {
|
||||
int xpos = sapx + tileFarm.xCoord;
|
||||
int ypos = tileFarm.yCoord + 2;
|
||||
int zpos = sapz + tileFarm.zCoord;
|
||||
if (getSaplinStack(tileFarm) != null) {
|
||||
Block saplin = Block.getBlockFromItem(getSaplinStack(tileFarm).getItem());
|
||||
int meta = getSaplinStack(tileFarm).getItemDamage();
|
||||
if (saplin != null && tileFarm.getWorldObj().getBlock(xpos, ypos, zpos) == Blocks.air && saplin.canBlockStay(tileFarm.getWorldObj(), xpos, ypos, zpos) && saplin.canPlaceBlockAt(tileFarm.getWorldObj(), xpos, ypos, zpos) && removeInputStack(new ItemStack(saplin, 1, meta), tileFarm)) {
|
||||
tileFarm.getWorldObj().setBlock(xpos, ypos, zpos, saplin, meta, 2);
|
||||
}
|
||||
sapx++;
|
||||
if (sapx == tileFarm.size) {
|
||||
sapx = -tileFarm.size;
|
||||
sapz++;
|
||||
}
|
||||
if (sapz >= tileFarm.size) {
|
||||
sapz = -tileFarm.size;
|
||||
sapx = -tileFarm.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void harvestTick(TileFarm tileFarm) {
|
||||
int overlap = 2;
|
||||
if (farmlandToPlace.isEmpty()) {
|
||||
if (!isHavrvesting) {
|
||||
harvestx = -tileFarm.size - overlap;
|
||||
harvesty = +2;
|
||||
harvestz = -tileFarm.size - overlap;
|
||||
isHavrvesting = true;
|
||||
} else {
|
||||
Block block = tileFarm.getWorldObj().getBlock(harvestx + tileFarm.xCoord, harvesty + tileFarm.yCoord, harvestz + tileFarm.zCoord);
|
||||
if (block instanceof BlockLeavesBase) {
|
||||
breakBlock(tileFarm, new Location(harvestx + tileFarm.xCoord, harvesty + tileFarm.yCoord, harvestz + tileFarm.zCoord));
|
||||
} else if (harvestableLogs.contains(block)) {
|
||||
breakBlock(tileFarm, new Location(harvestx + tileFarm.xCoord, harvesty + tileFarm.yCoord, harvestz + tileFarm.zCoord));
|
||||
;
|
||||
}
|
||||
harvestx++;
|
||||
if (harvestx >= tileFarm.size + overlap) {
|
||||
harvestx = -tileFarm.size - overlap;
|
||||
harvestz++;
|
||||
} else if (harvestz >= tileFarm.size + overlap) {
|
||||
harvestx = -tileFarm.size - overlap;
|
||||
harvestz = -tileFarm.size - overlap;
|
||||
harvesty++;
|
||||
} else if (harvesty > 12) {
|
||||
harvestx = 0;
|
||||
harvesty = 2;
|
||||
harvestz = 0;
|
||||
isHavrvesting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean removeInputStack(ItemStack stack, TileFarm tileFarm) {
|
||||
for (int i = 1; i < 9; i++) {
|
||||
if (ItemUtils.isItemEqual(stack, tileFarm.getStackInSlot(i), true, true)) {
|
||||
tileFarm.decrStackSize(i, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getSaplinStack(TileFarm tileFarm) {
|
||||
for (int i = 1; i < 14; i++) {
|
||||
if (tileFarm.getStackInSlot(i) != null && Block.getBlockFromItem(tileFarm.getStackInSlot(i).getItem()) instanceof BlockSapling) {
|
||||
return tileFarm.getStackInSlot(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void breakBlock(TileFarm farm, Location location) {
|
||||
World world = farm.getWorldObj();
|
||||
int x = location.x;
|
||||
int y = location.y;
|
||||
int z = location.z;
|
||||
world.destroyBlockInWorldPartially(world.rand.nextInt(), x, y, z, -1);
|
||||
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(x, y, z, world, block, meta,
|
||||
getFakePlayer((WorldServer) world));
|
||||
MinecraftForge.EVENT_BUS.post(breakEvent);
|
||||
|
||||
if (!breakEvent.isCanceled()) {
|
||||
List<ItemStack> stacks = getItemStackFromBlock((WorldServer) world, x, y, z);
|
||||
|
||||
if (stacks != null) {
|
||||
for (ItemStack s : stacks) {
|
||||
if (s != null) {
|
||||
addStackToInventroy(farm, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
world.playAuxSFXAtEntity(
|
||||
null,
|
||||
2001,
|
||||
x, y, z,
|
||||
Block.getIdFromBlock(block)
|
||||
+ (meta << 12));
|
||||
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<ItemStack> getItemStackFromBlock(WorldServer world, int i, int j, int k) {
|
||||
Block block = world.getBlock(i, j, k);
|
||||
|
||||
if (block == null || block.isAir(world, i, j, k)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
|
||||
ArrayList<ItemStack> dropsList = block.getDrops(world, i, j, k, meta, 0);
|
||||
float dropChance = ForgeEventFactory.fireBlockHarvesting(dropsList, world, block, i, j, k, meta, 0, 1.0F,
|
||||
false, getFakePlayer(world));
|
||||
|
||||
ArrayList<ItemStack> returnList = new ArrayList<ItemStack>();
|
||||
for (ItemStack s : dropsList) {
|
||||
if (world.rand.nextFloat() <= dropChance) {
|
||||
returnList.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
public EntityPlayer getFakePlayer(WorldServer world) {
|
||||
if (fakePlayer == null) {
|
||||
fakePlayer = FakePlayerFactory.get(world, gameProfile);
|
||||
} else {
|
||||
fakePlayer.worldObj = world;
|
||||
}
|
||||
|
||||
return fakePlayer;
|
||||
}
|
||||
|
||||
public void addStackToInventroy(TileFarm farm, ItemStack stack) {
|
||||
for (int i = 5; i < 14; i++) {
|
||||
if (farm.getStackInSlot(i) == null) {
|
||||
farm.setInventorySlotContents(i, stack);
|
||||
return;
|
||||
} else if (ItemUtils.isItemEqual(stack, farm.getStackInSlot(i), true, true) && farm.getStackInSlot(i).stackSize + stack.stackSize <= stack.getMaxStackSize()) {
|
||||
farm.decrStackSize(i, -stack.stackSize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -66,7 +66,6 @@ public class ModBlocks {
|
|||
public static Block heatGenerator;
|
||||
public static Block industrialSawmill;
|
||||
public static Block chargeBench;
|
||||
public static Block farm;
|
||||
|
||||
public static Block ore;
|
||||
public static Block storage;
|
||||
|
@ -249,9 +248,7 @@ public class ModBlocks {
|
|||
machineframe = new BlockMachineFrame(Material.iron);
|
||||
GameRegistry.registerBlock(machineframe, ItemBlockMachineFrame.class, "techreborn.machineFrame");
|
||||
|
||||
farm = new BlockFarm();
|
||||
GameRegistry.registerBlock(farm, "techreborn.farm");
|
||||
GameRegistry.registerTileEntity(TileFarm.class, "TileFarmTR");
|
||||
|
||||
|
||||
|
||||
registerOreDict();
|
||||
|
|
|
@ -78,7 +78,6 @@ public class ModItems {
|
|||
public static Item hammerIron;
|
||||
public static Item hammerDiamond;
|
||||
public static Item upgrades;
|
||||
public static Item farmPatten;
|
||||
|
||||
|
||||
public static void init() {
|
||||
|
@ -134,9 +133,6 @@ public class ModItems {
|
|||
hammerDiamond.setUnlocalizedName("hammerDiamond").setContainerItem(hammerDiamond);
|
||||
GameRegistry.registerItem(hammerDiamond, "hammerDiamond");
|
||||
|
||||
farmPatten = new ItemFarmPatten();
|
||||
GameRegistry.registerItem(farmPatten, "farmPatten");
|
||||
|
||||
cloakingDevice = new ItemCloakingDevice();
|
||||
GameRegistry.registerItem(cloakingDevice, "cloakingdevice");
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.item.ItemStack;
|
|||
import techreborn.partSystem.IPartProvider;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
import techreborn.partSystem.parts.CablePart;
|
||||
import techreborn.partSystem.parts.FarmInventoryCable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
@ -21,7 +20,6 @@ public class ModParts {
|
|||
ModPartRegistry.registerPart(part);
|
||||
}
|
||||
}
|
||||
ModPartRegistry.registerPart(new FarmInventoryCable());
|
||||
ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory",
|
||||
"ForgeMultipart");
|
||||
ModPartRegistry.addProvider("techreborn.partSystem.QLib.QModPartFactory", "qmunitylib");
|
||||
|
|
|
@ -25,7 +25,6 @@ import techreborn.blocks.BlockOre;
|
|||
import techreborn.blocks.BlockStorage;
|
||||
import techreborn.blocks.BlockStorage2;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.farm.FarmTree;
|
||||
import techreborn.items.ItemCells;
|
||||
import techreborn.items.ItemDusts;
|
||||
import techreborn.items.ItemDustsSmall;
|
||||
|
@ -67,7 +66,6 @@ public class
|
|||
addBlastFurnaceRecipes();
|
||||
addIndustrialGrinderRecipes();
|
||||
addImplosionCompressorRecipes();
|
||||
addLogs();
|
||||
}
|
||||
|
||||
static void addGeneralShapedRecipes() {
|
||||
|
@ -1544,11 +1542,4 @@ public class
|
|||
|
||||
}
|
||||
|
||||
static void addLogs() {
|
||||
FarmTree.harvestableLogs.add(Blocks.log);
|
||||
FarmTree.harvestableLogs.add(Blocks.log2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package techreborn.items;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.api.farm.IFarmLogicContainer;
|
||||
import techreborn.api.farm.IFarmLogicDevice;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.farm.FarmTree;
|
||||
|
||||
public class ItemFarmPatten extends Item implements IFarmLogicContainer {
|
||||
|
||||
|
||||
public ItemFarmPatten() {
|
||||
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
setUnlocalizedName("techreborn.farmPatten");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFarmLogicDevice getLogicFromStack(ItemStack stack) {
|
||||
return new FarmTree();
|
||||
}
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
package techreborn.partSystem.parts;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.client.render.RenderFarmInventoryCable;
|
||||
import techreborn.lib.Functions;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FarmInventoryCable extends ModPart implements IPartDesc {
|
||||
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
||||
public float center = 0.6F;
|
||||
public float offset = 0.10F;
|
||||
public Map<ForgeDirection, TileEntity> connectedSides;
|
||||
public int ticks = 0;
|
||||
public ItemStack stack;
|
||||
protected ForgeDirection[] dirs = ForgeDirection.values();
|
||||
private boolean[] connections = new boolean[6];
|
||||
private boolean hasCheckedSinceStartup;
|
||||
|
||||
public FarmInventoryCable() {
|
||||
connectedSides = new HashMap<ForgeDirection, TileEntity>();
|
||||
refreshBounding();
|
||||
}
|
||||
|
||||
public void refreshBounding() {
|
||||
float centerFirst = center - offset;
|
||||
double w = 0.7F / 2;
|
||||
|
||||
boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w,
|
||||
centerFirst - w, centerFirst + w, centerFirst + w, centerFirst
|
||||
+ w);
|
||||
|
||||
w = 0.4F / 2;
|
||||
int i = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
double xMin1 = (dir.offsetX < 0 ? 0.0
|
||||
: (dir.offsetX == 0 ? centerFirst - w : centerFirst + w));
|
||||
double xMax1 = (dir.offsetX > 0 ? 1.0
|
||||
: (dir.offsetX == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
double yMin1 = (dir.offsetY < 0 ? 0.0
|
||||
: (dir.offsetY == 0 ? centerFirst - w : centerFirst + w));
|
||||
double yMax1 = (dir.offsetY > 0 ? 1.0
|
||||
: (dir.offsetY == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
double zMin1 = (dir.offsetZ < 0 ? 0.0
|
||||
: (dir.offsetZ == 0 ? centerFirst - w : centerFirst + w));
|
||||
double zMax1 = (dir.offsetZ > 0 ? 1.0
|
||||
: (dir.offsetZ == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1,
|
||||
yMax1, zMax1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList(List<Vecs3dCube> boxes, Entity entity) {
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
boxes.add(boundingBoxes[Functions.getIntDirFromDirection(dir)]);
|
||||
}
|
||||
boxes.add(boundingBoxes[6]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vecs3dCube> getSelectionBoxes() {
|
||||
List<Vecs3dCube> vec3dCubeList = new ArrayList<Vecs3dCube>();
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
vec3dCubeList.add(boundingBoxes[Functions
|
||||
.getIntDirFromDirection(dir)]);
|
||||
}
|
||||
vec3dCubeList.add(boundingBoxes[6]);
|
||||
return vec3dCubeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vecs3dCube> getOcclusionBoxes() {
|
||||
List<Vecs3dCube> vecs3dCubesList = new ArrayList<Vecs3dCube>();
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
vecs3dCubesList.add(boundingBoxes[Functions
|
||||
.getIntDirFromDirection(dir)]);
|
||||
}
|
||||
return vecs3dCubesList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamic(Vecs3d translation, double delta) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(Vecs3d translation, int pass) {
|
||||
return RenderFarmInventoryCable.renderStatic(translation, pass, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
writeConnectedSidesToNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FarmInventoryCable";
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getItemTextureName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (worldObj != null) {
|
||||
if (worldObj.getTotalWorldTime() % 40 == 0 || hasCheckedSinceStartup == false) {
|
||||
checkConnectedSides();
|
||||
hasCheckedSinceStartup = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nearByChange() {
|
||||
checkConnectedSides();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
checkConnections(world, getX(), getY(), getZ());
|
||||
|
||||
checkConnectedSides();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModPart copy() {
|
||||
FarmInventoryCable part = new FarmInventoryCable();
|
||||
return part;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return new ItemStack(ModPartRegistry.getItem(getName()));
|
||||
}
|
||||
|
||||
public boolean shouldConnectTo(TileEntity entity, ForgeDirection dir) {
|
||||
if (entity == null) {
|
||||
return false;
|
||||
} else if (entity instanceof IEnergyTile) {
|
||||
return true;
|
||||
} else {
|
||||
return ModPartUtils.hasPart(entity.getWorldObj(), entity.xCoord,
|
||||
entity.yCoord, entity.zCoord, this.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void checkConnectedSides() {
|
||||
refreshBounding();
|
||||
connectedSides = new HashMap<ForgeDirection, TileEntity>();
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int d = Functions.getIntDirFromDirection(dir);
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
TileEntity te = world.getTileEntity(getX() + dir.offsetX, getY()
|
||||
+ dir.offsetY, getZ() + dir.offsetZ);
|
||||
if (shouldConnectTo(te, dir)) {
|
||||
if (ModPartUtils.checkOcclusion(getWorld(), getX(),
|
||||
getY(), getZ(), boundingBoxes[d])) {
|
||||
connectedSides.put(dir, te);
|
||||
}
|
||||
}
|
||||
if (te != null) {
|
||||
te.getWorldObj().markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
}
|
||||
checkConnections(world, getX(), getY(), getZ());
|
||||
getWorld().markBlockForUpdate(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public void checkConnections(World world, int x, int y, int z) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
ForgeDirection dir = dirs[i];
|
||||
int dx = x + dir.offsetX;
|
||||
int dy = y + dir.offsetY;
|
||||
int dz = z + dir.offsetZ;
|
||||
connections[i] = shouldConnectTo(world.getTileEntity(dx, dy, dz),
|
||||
dir);
|
||||
world.func_147479_m(dx, dy, dz);
|
||||
}
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
|
||||
private void readConnectedSidesFromNBT(NBTTagCompound tagCompound) {
|
||||
|
||||
NBTTagCompound ourCompound = tagCompound.getCompoundTag("connectedSides");
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
connections[dir.ordinal()] = ourCompound.getBoolean(dir.ordinal() + "");
|
||||
}
|
||||
checkConnectedSides();
|
||||
}
|
||||
|
||||
private void writeConnectedSidesToNBT(NBTTagCompound tagCompound) {
|
||||
|
||||
NBTTagCompound ourCompound = new NBTTagCompound();
|
||||
int i = 0;
|
||||
for (boolean b : connections) {
|
||||
ourCompound.setBoolean(i + "", b);
|
||||
i++;
|
||||
}
|
||||
|
||||
tagCompound.setTag("connectedSides", ourCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(NBTTagCompound tagCompound) {
|
||||
readConnectedSidesFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(NBTTagCompound tagCompound) {
|
||||
writeConnectedSidesToNBT(tagCompound);
|
||||
}
|
||||
}
|
|
@ -71,7 +71,6 @@ public class GuiManual extends GuiScreen{
|
|||
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Distillationtower), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Dragoneggenergysiphoner), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ElectricCraftingTable), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.farm), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.FusionCoil), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.FusionControlComputer), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Gasturbine), ""));
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.api.farm.IFarmLogicContainer;
|
||||
import techreborn.api.farm.IFarmLogicDevice;
|
||||
import techreborn.powerSystem.TilePowerAcceptor;
|
||||
import techreborn.util.Inventory;
|
||||
|
||||
public class TileFarm extends TilePowerAcceptor implements IInventory, IEnergyTile {
|
||||
|
||||
public Inventory inventory = new Inventory(14, "TileFarm", 64);
|
||||
|
||||
IFarmLogicDevice logicDevice;
|
||||
|
||||
public int size = 4;
|
||||
|
||||
public TileFarm() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
inventory.readFromNBT(tagCompound);
|
||||
super.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
inventory.writeToNBT(tagCompound);
|
||||
super.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (inventory.hasChanged) {
|
||||
if (inventory.getStackInSlot(0) != null && inventory.getStackInSlot(0).getItem() instanceof IFarmLogicContainer) {
|
||||
IFarmLogicContainer device = (IFarmLogicContainer) inventory.getStackInSlot(0).getItem();
|
||||
logicDevice = device.getLogicFromStack(inventory.getStackInSlot(0));
|
||||
} else {
|
||||
logicDevice = null;
|
||||
}
|
||||
}
|
||||
if (logicDevice != null) {
|
||||
logicDevice.tick(this);
|
||||
}
|
||||
super.updateEntity();
|
||||
inventory.hasChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
return inventory.decrStackSize(slot, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return inventory.getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return inventory.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return inventory.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
inventory.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
inventory.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return inventory.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 100000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(ForgeDirection direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(ForgeDirection direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 128;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue