mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-17 10:55:06 +00:00
Compiles for 1.9! Very buggy, some things are missing.
This commit is contained in:
1 parent
5d74c1254b
commit
7bf554b024
135 files changed
+1710
-1919
No files matched your search
@@ -31,7 +31,8 @@ public interface IArmorApiaristHelper {
|
||||
* @param entity Entity being attacked
|
||||
* @param cause Optional cause of attack, such as a bee effect identifier
|
||||
* @param doProtect Whether or not to actually do the side effects of protection
|
||||
* @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting
|
||||
* @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting.
|
||||
* 4 means full protection, but it can go higher if they are holding items like the smoker.
|
||||
* @since Forestry 4.2
|
||||
*/
|
||||
int wearsItems(EntityLivingBase entity, String cause, boolean doProtect);
|
||||
|
||||
@@ -7,6 +7,7 @@ package forestry.api.apiculture.hives;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
@@ -49,7 +50,7 @@ public interface IHiveRegistry {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public int getMeta() {
|
||||
|
||||
@@ -38,18 +38,12 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
public int wearsItems(EntityLivingBase entity, String cause, boolean doProtect) {
|
||||
int count = 0;
|
||||
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
ItemStack armorItem = entity.getEquipmentInSlot(i);
|
||||
for (ItemStack armorItem : entity.getEquipmentAndArmor()) {
|
||||
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack heldItem = entity.getHeldItem();
|
||||
if (isArmorApiarist(heldItem, entity, cause, doProtect)) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -199,10 +199,11 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
PluginCore.rootCommand.addChildCommand(new CommandBee());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTriggers() {
|
||||
ApicultureTriggers.initialize();
|
||||
}
|
||||
// TODO: Buildcraft for 1.9
|
||||
// @Override
|
||||
// public void registerTriggers() {
|
||||
// ApicultureTriggers.initialize();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void doInit() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -63,7 +64,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
@@ -65,11 +66,17 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
|
||||
private static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
|
||||
|
||||
private enum State implements IStringSerializable {
|
||||
ON, OFF;
|
||||
ON("on"), OFF("off");
|
||||
|
||||
private final String name;
|
||||
|
||||
State(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import forestry.core.tiles.TileForestry;
|
||||
|
||||
public enum BlockTypeApiculture implements IBlockType {
|
||||
APIARY(0, TileApiary.class, "apiary"),
|
||||
BEE_HOUSE(1, TileBeeHouse.class, "bee.house");
|
||||
BEE_HOUSE(1, TileBeeHouse.class, "bee_house");
|
||||
|
||||
public static final BlockTypeApiculture[] VALUES = values();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import forestry.core.tiles.TileForestry;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
|
||||
public enum BlockTypeApicultureTesr implements IBlockTypeTesr {
|
||||
APIARIST_CHEST(0, TileApiaristChest.class, "api.chest", Proxies.render.getRenderChest("apiaristchest"), TileNaturalistChest.chestBoundingBox);
|
||||
APIARIST_CHEST(0, TileApiaristChest.class, "api_chest", Proxies.render.getRenderChest("apiaristchest"), TileNaturalistChest.chestBoundingBox);
|
||||
|
||||
public static final BlockTypeApicultureTesr[] VALUES = values();
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
|
||||
flowerPotTile.markDirty();
|
||||
|
||||
if (!world.setBlockState(pos, world.getBlockState(pos).getBlock().getStateFromMeta(1), 2)) {
|
||||
world.markBlockForUpdate(pos);
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -13,6 +13,9 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -82,8 +85,8 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
continue;
|
||||
}
|
||||
|
||||
world.playSoundEffect(housingCoords.getX(), housingCoords.getY(), housingCoords.getZ(), "mob.creeper", 4F,
|
||||
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
|
||||
float pitch = (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F;
|
||||
world.playSound((EntityPlayer)null, housingCoords.getX(), housingCoords.getY(), housingCoords.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, pitch);
|
||||
storedData.setInteger(indexExplosionTimer, 2); // Set explosion timer
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
@@ -85,7 +86,8 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = world.getBlockState(posBlock).getBlock();
|
||||
IBlockState blockState = world.getBlockState(posBlock);
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if (block instanceof BlockAlveary) {
|
||||
continue;
|
||||
@@ -96,7 +98,7 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (block.getBlockHardness(world, posBlock) < 0) {
|
||||
if (block.getBlockHardness(blockState, world, posBlock) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.apiculture.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -20,7 +21,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import forestry.apiculture.blocks.BlockCandle;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
|
||||
public class ItemBlockCandle extends ItemBlockForestry<BlockCandle> {
|
||||
public class ItemBlockCandle extends ItemBlockForestry<BlockCandle> implements IItemColor {
|
||||
|
||||
public ItemBlockCandle(Block block) {
|
||||
super(block);
|
||||
@@ -28,7 +29,7 @@ public class ItemBlockCandle extends ItemBlockForestry<BlockCandle> {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int pass) {
|
||||
public int getColorFromItemstack(ItemStack stack, int pass) {
|
||||
int value = 0xffffff;
|
||||
if (pass == 1 && stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
@@ -177,7 +177,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
BlockPos pos = new BlockPos(slabX, slabY, slabZ);
|
||||
IBlockState state = worldObj.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
if (!BlockUtil.isWoodSlabBlock(block, worldObj, pos)) {
|
||||
if (!BlockUtil.isWoodSlabBlock(state, block, worldObj, pos)) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSlabs"));
|
||||
}
|
||||
|
||||
@@ -196,8 +196,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
if (isCoordInMultiblock(airX, airY, airZ)) {
|
||||
continue;
|
||||
}
|
||||
Block block = BlockUtil.getBlock(worldObj, new BlockPos(airX, airY, airZ));
|
||||
if (block.isOpaqueCube()) {
|
||||
IBlockState blockState = worldObj.getBlockState(new BlockPos(airX, airY, airZ));
|
||||
Block block = blockState.getBlock();
|
||||
if (block.isOpaqueCube(blockState)) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSpace"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,23 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.apiculture.trigger.ApicultureTriggers;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import buildcraft.api.statements.ITriggerInternal;
|
||||
import buildcraft.api.statements.ITriggerProvider;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public class TileAlvearyPlain extends TileAlveary implements ITriggerProvider {
|
||||
//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public class TileAlvearyPlain extends TileAlveary {//implements ITriggerProvider {
|
||||
|
||||
@Override
|
||||
public boolean allowsAutomation() {
|
||||
@@ -34,18 +19,19 @@ public class TileAlvearyPlain extends TileAlveary implements ITriggerProvider {
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
Collection<ITriggerExternal> res = new ArrayList<>();
|
||||
res.add(ApicultureTriggers.missingQueen);
|
||||
res.add(ApicultureTriggers.missingDrone);
|
||||
return res;
|
||||
}
|
||||
// TODO: buildcraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// Collection<ITriggerExternal> res = new ArrayList<>();
|
||||
// res.add(ApicultureTriggers.missingQueen);
|
||||
// res.add(ApicultureTriggers.missingDrone);
|
||||
// return res;
|
||||
// }
|
||||
}
|
||||
@@ -13,14 +13,9 @@ package forestry.apiculture.tiles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
@@ -33,9 +28,6 @@ import forestry.apiculture.gui.ContainerBeeHousing;
|
||||
import forestry.apiculture.gui.GuiBeeHousing;
|
||||
import forestry.apiculture.inventory.IApiaryInventory;
|
||||
import forestry.apiculture.inventory.InventoryApiary;
|
||||
import forestry.apiculture.trigger.ApicultureTriggers;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public class TileApiary extends TileBeeHousingBase implements IApiary {
|
||||
private final IBeeModifier beeModifier = new ApiaryBeeModifier();
|
||||
@@ -76,15 +68,16 @@ public class TileApiary extends TileBeeHousingBase implements IApiary {
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
res.add(ApicultureTriggers.missingQueen);
|
||||
res.add(ApicultureTriggers.missingDrone);
|
||||
res.add(ApicultureTriggers.noFrames);
|
||||
return res;
|
||||
}
|
||||
// TODO: buildcraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
// res.add(ApicultureTriggers.missingQueen);
|
||||
// res.add(ApicultureTriggers.missingDrone);
|
||||
// res.add(ApicultureTriggers.noFrames);
|
||||
// return res;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
|
||||
@@ -12,15 +12,16 @@ package forestry.apiculture.trigger;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class ApicultureTriggers {
|
||||
public static Trigger noFrames;
|
||||
public static Trigger missingQueen;
|
||||
public static Trigger missingDrone;
|
||||
|
||||
public static void initialize() {
|
||||
noFrames = new TriggerNoFrames();
|
||||
|
||||
missingQueen = new TriggerMissingQueen();
|
||||
missingDrone = new TriggerMissingDrone();
|
||||
}
|
||||
// public static Trigger noFrames;
|
||||
// public static Trigger missingQueen;
|
||||
// public static Trigger missingDrone;
|
||||
//
|
||||
// public static void initialize() {
|
||||
// noFrames = new TriggerNoFrames();
|
||||
//
|
||||
// missingQueen = new TriggerMissingQueen();
|
||||
// missingDrone = new TriggerMissingDrone();
|
||||
// }
|
||||
}
|
||||
@@ -10,34 +10,25 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.trigger;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerMissingDrone {//extends Trigger {
|
||||
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
public class TriggerMissingDrone extends Trigger {
|
||||
|
||||
public TriggerMissingDrone() {
|
||||
super("missingDrone");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
|
||||
if (!(tile instanceof IErrorLogicSource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IErrorLogicSource apiary = (IErrorLogicSource) tile;
|
||||
return apiary.getErrorLogic().contains(EnumErrorCode.NO_DRONE);
|
||||
}
|
||||
// public TriggerMissingDrone() {
|
||||
// super("missingDrone");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
//
|
||||
// if (!(tile instanceof IErrorLogicSource)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// IErrorLogicSource apiary = (IErrorLogicSource) tile;
|
||||
// return apiary.getErrorLogic().contains(EnumErrorCode.NO_DRONE);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -10,33 +10,24 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.trigger;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
public class TriggerMissingQueen {//extends Trigger {
|
||||
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
public class TriggerMissingQueen extends Trigger {
|
||||
|
||||
public TriggerMissingQueen() {
|
||||
super("missingQueen");
|
||||
}
|
||||
// public TriggerMissingQueen() {
|
||||
// super("missingQueen");
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
|
||||
if (!(tile instanceof IErrorLogicSource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IErrorLogicSource apiary = (IErrorLogicSource) tile;
|
||||
return apiary.getErrorLogic().contains(EnumErrorCode.NO_QUEEN);
|
||||
}
|
||||
// TODO: buildcraft for 1.9
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
//
|
||||
// if (!(tile instanceof IErrorLogicSource)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// IErrorLogicSource apiary = (IErrorLogicSource) tile;
|
||||
// return apiary.getErrorLogic().contains(EnumErrorCode.NO_QUEEN);
|
||||
// }
|
||||
}
|
||||
@@ -10,37 +10,30 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.trigger;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.apiculture.inventory.InventoryApiary;
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
public class TriggerNoFrames {//extends Trigger {
|
||||
|
||||
public class TriggerNoFrames extends Trigger {
|
||||
|
||||
public TriggerNoFrames() {
|
||||
super("noFrames");
|
||||
}
|
||||
// public TriggerNoFrames() {
|
||||
// super("noFrames");
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
|
||||
if (!(tile instanceof TileApiary)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileApiary apiary = (TileApiary) tile;
|
||||
|
||||
InventoryApiary inventory = (InventoryApiary) apiary.getInternalInventory();
|
||||
|
||||
return inventory.getFrames().isEmpty();
|
||||
}
|
||||
// TODO: buildcraft for 1.9
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
//
|
||||
// if (!(tile instanceof TileApiary)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileApiary apiary = (TileApiary) tile;
|
||||
//
|
||||
// InventoryApiary inventory = (InventoryApiary) apiary.getInternalInventory();
|
||||
//
|
||||
// return inventory.getFrames().isEmpty();
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import forestry.core.tiles.TileForestry;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
|
||||
public enum BlockTypeArboricultureTesr implements IBlockTypeTesr {
|
||||
ARB_CHEST(0, TileArboristChest.class, "arb.chest", Proxies.render.getRenderChest("arbchest"), TileNaturalistChest.chestBoundingBox);
|
||||
ARB_CHEST(0, TileArboristChest.class, "arb_chest", Proxies.render.getRenderChest("arbchest"), TileNaturalistChest.chestBoundingBox);
|
||||
|
||||
public static final BlockTypeArboricultureTesr[] VALUES = values();
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.google.common.base.Optional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -55,7 +56,7 @@ public class PropertyTree extends PropertyAllele<IAlleleTreeSpecies> {
|
||||
|
||||
@Override
|
||||
public String getName(IAlleleTreeSpecies value) {
|
||||
return value.getModelName().replace("tree", "");
|
||||
return value.getModelName().replace("tree", "").toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.commands;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -46,8 +47,9 @@ public final class TreeGenHelper {
|
||||
}else{
|
||||
pos = BlockUtil.getNextReplaceableUpPos(world, pos);
|
||||
}
|
||||
|
||||
if(BlockUtil.canPlaceTree(world, pos)){
|
||||
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (BlockUtil.canPlaceTree(blockState, world, pos)){
|
||||
if (gen instanceof WorldGenBase) {
|
||||
((WorldGenBase) gen).generate(world, pos, false);
|
||||
} else {
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.genetics;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.arboriculture.EnumGrowthConditions;
|
||||
import forestry.api.arboriculture.IGrowthProvider;
|
||||
@@ -56,8 +56,6 @@ public class GrowthProvider implements IGrowthProvider {
|
||||
}
|
||||
|
||||
protected static EnumGrowthConditions getConditionsFromRainfall(World world, BlockPos pos, float min, float max) {
|
||||
|
||||
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos);
|
||||
float humidity = ForestryAPI.climateManager.getHumidity(world, pos);
|
||||
|
||||
if (humidity < min || humidity > max) {
|
||||
@@ -68,8 +66,6 @@ public class GrowthProvider implements IGrowthProvider {
|
||||
}
|
||||
|
||||
protected static EnumGrowthConditions getConditionsFromTemperature(World world, BlockPos pos, float min, float max) {
|
||||
|
||||
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos);
|
||||
float biomeTemperature = ForestryAPI.climateManager.getTemperature(world, pos);
|
||||
if (biomeTemperature < min || biomeTemperature > max) {
|
||||
return EnumGrowthConditions.HOSTILE;
|
||||
@@ -110,7 +106,8 @@ public class GrowthProvider implements IGrowthProvider {
|
||||
for (int y = start.getY(); y < start.getY() + area.getY(); y++) {
|
||||
for (int z = start.getZ(); z < start.getZ() + area.getZ(); z++) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
if (!world.isAirBlock(pos) && !BlockUtil.isReplaceableBlock(world, pos)) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (!world.isAirBlock(pos) && !BlockUtil.isReplaceableBlock(blockState, world, pos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.arboriculture.genetics;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -1112,7 +1113,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name();
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public int getMetadata() {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SaplingStateMapper extends ForestryStateMapper {
|
||||
if (allele instanceof IAlleleTreeSpecies) {
|
||||
IAlleleTreeSpecies tree = (IAlleleTreeSpecies) allele;
|
||||
IBlockState state = block.getDefaultState().withProperty(BlockSapling.TREE, tree);
|
||||
LinkedHashMap<IProperty, Comparable> linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
|
||||
LinkedHashMap<IProperty<?>, Comparable<?>> linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
|
||||
String modID = tree.getModID();
|
||||
if (modID == null) {
|
||||
modID = Constants.MOD_ID;
|
||||
|
||||
@@ -190,6 +190,6 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
} else {
|
||||
allele = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele(Constants.MOD_ID + ".fruitCocoa");
|
||||
}
|
||||
worldObj.markBlockForUpdate(getPos());
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
|
||||
tree.mate(individual);
|
||||
worldObj.markBlockForUpdate(getPos());
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -380,7 +380,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
setTree(tree);
|
||||
|
||||
worldObj.markBlockForUpdate(getPos());
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
return;
|
||||
}
|
||||
colourFruits = newColourFruits;
|
||||
worldObj.markBlockForUpdate(getPos());
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
|
||||
/* IFRUITBEARER */
|
||||
|
||||
@@ -43,7 +43,7 @@ public class EventHandlerCore {
|
||||
}
|
||||
|
||||
for (IPickupHandler handler : PluginManager.pickupHandlers) {
|
||||
if (handler.onItemPickup(event.entityPlayer, event.item)) {
|
||||
if (handler.onItemPickup(event.getEntityPlayer(), event.getItem())) {
|
||||
event.setResult(Result.ALLOW);
|
||||
return;
|
||||
}
|
||||
@@ -65,21 +65,21 @@ public class EventHandlerCore {
|
||||
@SubscribeEvent
|
||||
public void handleWorldLoad(WorldEvent.Load event) {
|
||||
for (ISaveEventHandler handler : PluginManager.saveEventHandlers) {
|
||||
handler.onWorldLoad(event.world);
|
||||
handler.onWorldLoad(event.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handleWorldSave(WorldEvent.Save event) {
|
||||
for (ISaveEventHandler handler : PluginManager.saveEventHandlers) {
|
||||
handler.onWorldSave(event.world);
|
||||
handler.onWorldSave(event.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handleWorldUnload(WorldEvent.Unload event) {
|
||||
for (ISaveEventHandler handler : PluginManager.saveEventHandlers) {
|
||||
handler.onWorldUnload(event.world);
|
||||
handler.onWorldUnload(event.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TickHandlerCoreServer {
|
||||
|
||||
if (Config.doRetrogen) {
|
||||
World world = event.world;
|
||||
int dimensionID = world.provider.getDimensionId();
|
||||
int dimensionID = world.provider.getDimension();
|
||||
List<ChunkCoords> chunkList = chunkRegenList.get(dimensionID);
|
||||
|
||||
if (!chunkList.isEmpty()) {
|
||||
@@ -102,7 +102,7 @@ public class TickHandlerCoreServer {
|
||||
public final int zCoord;
|
||||
|
||||
public ChunkCoords(Chunk chunk) {
|
||||
this.dimension = chunk.getWorld().provider.getDimensionId();
|
||||
this.dimension = chunk.getWorld().provider.getDimension();
|
||||
this.xCoord = chunk.xPosition;
|
||||
this.zCoord = chunk.zPosition;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.blocks;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -44,7 +45,7 @@ public class BlockResourceOre extends Block implements IItemModelRegister, IBloc
|
||||
});
|
||||
|
||||
public BlockResourceOre() {
|
||||
super(Material.rock);
|
||||
super(Material.ROCK);
|
||||
setHardness(3F);
|
||||
setResistance(5F);
|
||||
setCreativeTab(CreativeTabForestry.tabForestry);
|
||||
@@ -97,11 +98,6 @@ public class BlockResourceOre extends Block implements IItemModelRegister, IBloc
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageValue(World world, BlockPos pos) {
|
||||
return getMetaFromState(world.getBlockState(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMe
|
||||
|
||||
public enum SoilType implements IStringSerializable {
|
||||
HUMUS("humus"),
|
||||
BOG_EARTH("bog.earth"),
|
||||
BOG_EARTH("bog_earth"),
|
||||
PEAT("peat");
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.core.circuits;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -30,7 +31,7 @@ import forestry.api.core.IModelManager;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.items.ItemForestry;
|
||||
|
||||
public class ItemCircuitBoard extends ItemForestry {
|
||||
public class ItemCircuitBoard extends ItemForestry implements IItemColor {
|
||||
|
||||
public ItemCircuitBoard() {
|
||||
setHasSubtypes(true);
|
||||
@@ -62,9 +63,9 @@ public class ItemCircuitBoard extends ItemForestry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemstack, int pass) {
|
||||
public int getColorFromItemstack(ItemStack itemstack, int tintIndex) {
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.values()[itemstack.getItemDamage()];
|
||||
if (pass == 0) {
|
||||
if (tintIndex == 0) {
|
||||
return type.getPrimaryColor();
|
||||
} else {
|
||||
return type.getSecondaryColor();
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.core.commands;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import forestry.core.utils.Translator;
|
||||
@@ -32,7 +33,7 @@ public class CommandPlugins extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] args) throws WrongUsageException {
|
||||
public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length == 0) {
|
||||
listPluginsForSender(sender);
|
||||
} else {
|
||||
@@ -75,7 +76,7 @@ public class CommandPlugins extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length == 1) {
|
||||
listPluginInfoForSender(sender, args[0]);
|
||||
} else {
|
||||
|
||||
@@ -22,8 +22,10 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerNotFoundException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -59,26 +61,27 @@ public final class CommandSaveStats extends SubCommand {
|
||||
this.modeHelper = modeHelper;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters, BlockPos pos) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
|
||||
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(args, server.getAllUsernames());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] args) throws PlayerNotFoundException {
|
||||
public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length > 1) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
World world = CommandHelpers.getWorld(sender, this);
|
||||
World world = sender.getEntityWorld();
|
||||
|
||||
EntityPlayerMP player;
|
||||
if (args.length > 0) {
|
||||
player = CommandBase.getPlayer((MinecraftServer) sender, (ICommandSender) args[0], null);
|
||||
player = CommandBase.getPlayer(server, sender, args[0]);
|
||||
} else {
|
||||
player = CommandBase.getPlayer((MinecraftServer) sender, (ICommandSender) sender.getName(), null);
|
||||
player = CommandBase.getPlayer(server, sender, sender.getName());
|
||||
}
|
||||
|
||||
Collection<String> statistics = new ArrayList<>();
|
||||
|
||||
+89
-89
@@ -1,90 +1,90 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.entities;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityFXColoredDropParticle extends EntityFX {
|
||||
|
||||
/**
|
||||
* The height of the current bob
|
||||
*/
|
||||
private int bobTimer;
|
||||
|
||||
public EntityFXColoredDropParticle(World world, double x, double y, double z, float red, float green, float blue) {
|
||||
super(world, x, y, z);
|
||||
this.particleRed = red;
|
||||
this.particleGreen = green;
|
||||
this.particleBlue = blue;
|
||||
|
||||
this.setParticleTextureIndex(113);
|
||||
this.setSize(0.01F, 0.01F);
|
||||
this.particleGravity = 0.06F;
|
||||
this.bobTimer = 40;
|
||||
this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
||||
this.ySpeed -= this.particleGravity;
|
||||
|
||||
if (this.bobTimer-- > 0) {
|
||||
this.xSpeed *= 0.02D;
|
||||
this.ySpeed *= 0.02D;
|
||||
this.zSpeed *= 0.02D;
|
||||
this.setParticleTextureIndex(113);
|
||||
} else {
|
||||
this.setParticleTextureIndex(112);
|
||||
}
|
||||
|
||||
this.moveEntity(this.xSpeed, this.ySpeed, this.zSpeed);
|
||||
this.xSpeed *= 0.9800000190734863D;
|
||||
this.ySpeed *= 0.9800000190734863D;
|
||||
this.zSpeed *= 0.9800000190734863D;
|
||||
|
||||
if (this.particleMaxAge-- <= 0) {
|
||||
this.setExpired();
|
||||
}
|
||||
|
||||
if (this.isCollided) {
|
||||
this.setParticleTextureIndex(114);
|
||||
|
||||
this.xSpeed *= 0.699999988079071D;
|
||||
this.zSpeed *= 0.699999988079071D;
|
||||
}
|
||||
|
||||
IBlockState state = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)));
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial(state);
|
||||
|
||||
if (material.isLiquid() || material.isSolid()) {
|
||||
double d0 = MathHelper.floor_double(this.posY) + 1 - BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state));
|
||||
|
||||
if (this.posY < d0) {
|
||||
this.setExpired();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.entities;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityFXColoredDripParticle extends EntityFX {
|
||||
|
||||
/**
|
||||
* The height of the current bob
|
||||
*/
|
||||
private int bobTimer;
|
||||
|
||||
public EntityFXColoredDripParticle(World world, double x, double y, double z, float red, float green, float blue) {
|
||||
super(world, x, y, z);
|
||||
this.particleRed = red;
|
||||
this.particleGreen = green;
|
||||
this.particleBlue = blue;
|
||||
|
||||
this.setParticleTextureIndex(113);
|
||||
this.setSize(0.01F, 0.01F);
|
||||
this.particleGravity = 0.06F;
|
||||
this.bobTimer = 40;
|
||||
this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
||||
this.ySpeed -= this.particleGravity;
|
||||
|
||||
if (this.bobTimer-- > 0) {
|
||||
this.xSpeed *= 0.02D;
|
||||
this.ySpeed *= 0.02D;
|
||||
this.zSpeed *= 0.02D;
|
||||
this.setParticleTextureIndex(113);
|
||||
} else {
|
||||
this.setParticleTextureIndex(112);
|
||||
}
|
||||
|
||||
this.moveEntity(this.xSpeed, this.ySpeed, this.zSpeed);
|
||||
this.xSpeed *= 0.9800000190734863D;
|
||||
this.ySpeed *= 0.9800000190734863D;
|
||||
this.zSpeed *= 0.9800000190734863D;
|
||||
|
||||
if (this.particleMaxAge-- <= 0) {
|
||||
this.setExpired();
|
||||
}
|
||||
|
||||
if (this.isCollided) {
|
||||
this.setParticleTextureIndex(114);
|
||||
|
||||
this.xSpeed *= 0.699999988079071D;
|
||||
this.zSpeed *= 0.699999988079071D;
|
||||
}
|
||||
|
||||
IBlockState state = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)));
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial(state);
|
||||
|
||||
if (material.isLiquid() || material.isSolid()) {
|
||||
double d0 = MathHelper.floor_double(this.posY) + 1 - BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state));
|
||||
|
||||
if (this.posY < d0) {
|
||||
this.setExpired();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,18 @@ import java.awt.Color;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -34,7 +38,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.entities.EntityFXColoredDropParticle;
|
||||
import forestry.core.entities.EntityFXColoredDripParticle;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
public class BlockForestryFluid extends BlockFluidClassic implements IItemModelRegister {
|
||||
@@ -52,7 +56,7 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
|
||||
}
|
||||
|
||||
private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) {
|
||||
super(fluid, Material.water);
|
||||
super(fluid, Material.WATER);
|
||||
|
||||
setDensity(fluid.getDensity());
|
||||
|
||||
@@ -72,22 +76,61 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
|
||||
return FluidRegistry.getFluid(fluidName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from {@link BlockLiquid#randomDisplayTick(IBlockState, World, BlockPos, Random)}
|
||||
* and modified to have colored particles.
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(world, new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())) && !world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 2, pos.getZ())).getBlock().getMaterial().blocksMovement()) {
|
||||
double px = pos.getX() + rand.nextFloat();
|
||||
double py = pos.getY() - 1.05D;
|
||||
double pz = pos.getZ() + rand.nextFloat();
|
||||
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
||||
double d0 = (double) pos.getX();
|
||||
double d1 = (double) pos.getY();
|
||||
double d2 = (double) pos.getZ();
|
||||
|
||||
EntityFX fx = new EntityFXColoredDropParticle(world, px, py, pz, color.getRed(), color.getGreen(), color.getBlue());
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
|
||||
if (this.blockMaterial == Material.WATER) {
|
||||
int i = stateIn.getValue(LEVEL);
|
||||
|
||||
if (i > 0 && i < 8) {
|
||||
if (rand.nextInt(64) == 0) {
|
||||
worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() + 0.5F, false);
|
||||
}
|
||||
} else if (rand.nextInt(10) == 0) {
|
||||
worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double) rand.nextFloat(), d1 + (double) rand.nextFloat(), d2 + (double) rand.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.blockMaterial == Material.LAVA && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && !worldIn.getBlockState(pos.up()).isOpaqueCube()) {
|
||||
if (rand.nextInt(100) == 0) {
|
||||
double d8 = d0 + (double) rand.nextFloat();
|
||||
double d4 = d1 + stateIn.getBoundingBox(worldIn, pos).maxY;
|
||||
double d6 = d2 + (double) rand.nextFloat();
|
||||
worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D);
|
||||
worldIn.playSound(d8, d4, d6, SoundEvents.BLOCK_LAVA_POP, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
|
||||
}
|
||||
|
||||
if (rand.nextInt(200) == 0) {
|
||||
worldIn.playSound(d0, d1, d2, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.nextInt(10) == 0 && worldIn.getBlockState(pos.down()).isFullyOpaque()) {
|
||||
Material material = worldIn.getBlockState(pos.down(2)).getMaterial();
|
||||
|
||||
if (!material.blocksMovement() && !material.isLiquid()) {
|
||||
double px = d0 + (double) rand.nextFloat();
|
||||
double py = d1 - 1.05D;
|
||||
double pz = d2 + (double) rand.nextFloat();
|
||||
|
||||
EntityFX fx = new EntityFXColoredDripParticle(worldIn, px, py, pz, color.getRed(), color.getGreen(), color.getBlue());
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDisplace(IBlockAccess world, BlockPos pos) {
|
||||
if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (blockState.getBlock().getMaterial(blockState).isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
return super.canDisplace(world, pos);
|
||||
@@ -95,7 +138,8 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
|
||||
|
||||
@Override
|
||||
public boolean displaceIfPossible(World world, BlockPos pos) {
|
||||
if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (blockState.getBlock().getMaterial(blockState).isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
return super.displaceIfPossible(world, pos);
|
||||
@@ -130,13 +174,13 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial() {
|
||||
public Material getMaterial(IBlockState state) {
|
||||
// Fahrenheit 451 = 505.928 Kelvin
|
||||
// The temperature at which book-paper catches fire, and burns.
|
||||
if (temperature > 505) {
|
||||
return Material.lava;
|
||||
return Material.LAVA;
|
||||
} else {
|
||||
return super.getMaterial();
|
||||
return super.getMaterial(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,21 +199,22 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
|
||||
int z = pos.getZ();
|
||||
|
||||
// Start fires if the fluid is lava-like
|
||||
if (getMaterial() == Material.lava) {
|
||||
if (getMaterial(state) == Material.LAVA) {
|
||||
int rangeUp = rand.nextInt(3);
|
||||
|
||||
for (int i = 0; i < rangeUp; ++i) {
|
||||
x += rand.nextInt(3) - 1;
|
||||
++y;
|
||||
z += rand.nextInt(3) - 1;
|
||||
Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
|
||||
IBlockState blockState = world.getBlockState(new BlockPos(x, y, z));
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air) {
|
||||
if (block.getMaterial(blockState) == Material.AIR) {
|
||||
if (isNeighborFlammable(world, x, y, z)) {
|
||||
world.setBlockState(new BlockPos(x, y, z), Blocks.FIRE.getDefaultState());
|
||||
return;
|
||||
}
|
||||
} else if (block.getMaterial().blocksMovement()) {
|
||||
} else if (block.getMaterial(blockState).blocksMovement()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.core.genetics.mutations;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
@@ -33,7 +32,6 @@ public class MutationConditionHumidity implements IMutationCondition {
|
||||
|
||||
@Override
|
||||
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos);
|
||||
EnumHumidity biomeHumidity = EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(world, pos));
|
||||
|
||||
if (biomeHumidity.ordinal() < minHumidity.ordinal() || biomeHumidity.ordinal() > maxHumidity.ordinal()) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MutationConditionTemperature implements IMutationCondition {
|
||||
|
||||
@Override
|
||||
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos);
|
||||
BiomeGenBase biome = world.getBiomeProvider().getBiomeGenerator(pos);
|
||||
EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, world, pos);
|
||||
|
||||
if (biomeTemperature.ordinal() < minTemperature.ordinal() || biomeTemperature.ordinal() > maxTemperature.ordinal()) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class ContainerLiquidTanksSocketed<T extends TileEntity & ILiqui
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
tile.getTankManager().updateGuiData(this, crafters);
|
||||
tile.getTankManager().updateGuiData(this, listeners);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
@@ -64,6 +65,7 @@ public class SlotCrafter extends Slot {
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
|
||||
* Copied from {@link SlotCrafting#onCrafting(ItemStack)}
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(ItemStack stack) {
|
||||
@@ -74,47 +76,43 @@ public class SlotCrafter extends Slot {
|
||||
this.amountCrafted = 0;
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.CRAFTING_TABLE)) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.buildWorkBench);
|
||||
this.thePlayer.addStat(AchievementList.BUILD_WORK_BENCH);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemPickaxe) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.buildPickaxe);
|
||||
this.thePlayer.addStat(AchievementList.BUILD_PICKAXE);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.FURNACE)) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.buildFurnace);
|
||||
this.thePlayer.addStat(AchievementList.BUILD_FURNACE);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemHoe) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.buildHoe);
|
||||
this.thePlayer.addStat(AchievementList.BUILD_HOE);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Items.BREAD) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.makeBread);
|
||||
this.thePlayer.addStat(AchievementList.MAKE_BREAD);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Items.CAKE) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.bakeCake);
|
||||
this.thePlayer.addStat(AchievementList.BAKE_CAKE);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemPickaxe && ((ItemPickaxe) stack.getItem()).getToolMaterial() != Item.ToolMaterial.WOOD) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.buildBetterPickaxe);
|
||||
this.thePlayer.addStat(AchievementList.BUILD_BETTER_PICKAXE);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemSword) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.buildSword);
|
||||
this.thePlayer.addStat(AchievementList.BUILD_SWORD);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.ENCHANTING_TABLE)) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.enchantments);
|
||||
this.thePlayer.addStat(AchievementList.ENCHANTMENTS);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.BOOKSHELF)) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.bookcase);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Items.GOLDEN_APPLE && stack.getMetadata() == 1) {
|
||||
this.thePlayer.triggerAchievement(AchievementList.overpowered);
|
||||
this.thePlayer.addStat(AchievementList.BOOKCASE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ package forestry.core.items;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemAssemblyKit extends ItemForestry {
|
||||
@@ -24,12 +27,12 @@ public class ItemAssemblyKit extends ItemForestry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
if (!world.isRemote) {
|
||||
itemstack.stackSize--;
|
||||
EntityItem entity = new EntityItem(world, entityplayer.posX, entityplayer.posY, entityplayer.posZ, assembled.copy());
|
||||
world.spawnEntityInWorld(entity);
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
if (!worldIn.isRemote) {
|
||||
itemStackIn.stackSize--;
|
||||
EntityItem entity = new EntityItem(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ, assembled.copy());
|
||||
worldIn.spawnEntityInWorld(entity);
|
||||
}
|
||||
return itemstack;
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, itemStackIn);
|
||||
}
|
||||
}
|
||||
+40
-32
@@ -1,32 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemForestryBonemeal extends ItemForestry {
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (ItemDye.applyBonemeal(stack, world, pos, player)) {
|
||||
if (!world.isRemote) {
|
||||
world.playAuxSFX(2005, pos, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFertilizer extends ItemForestry {
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (ItemDye.applyBonemeal(stack, worldIn, pos, playerIn)) {
|
||||
if (!worldIn.isRemote) {
|
||||
worldIn.playAuxSFX(2005, pos, 0);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.FoodStats;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemLiquidContainerDrinkable extends ItemLiquidContainer {
|
||||
@@ -15,11 +23,22 @@ public class ItemLiquidContainerDrinkable extends ItemLiquidContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player) {
|
||||
stack.stackSize--;
|
||||
FoodStats foodStats = player.getFoodStats();
|
||||
foodStats.addStats(properties.getHealAmount(), properties.getSaturationModifier());
|
||||
world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
||||
if (entityLiving instanceof EntityPlayer && !((EntityPlayer)entityLiving).capabilities.isCreativeMode) {
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
--stack.stackSize;
|
||||
}
|
||||
|
||||
if (!worldIn.isRemote) {
|
||||
FoodStats foodStats = player.getFoodStats();
|
||||
foodStats.addStats(properties.getHealAmount(), properties.getSaturationModifier());
|
||||
worldIn.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
player.addStat(StatList.getObjectUseStats(this));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -34,10 +53,12 @@ public class ItemLiquidContainerDrinkable extends ItemLiquidContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
if (entityplayer.canEat(false)) {
|
||||
entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack));
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
if (playerIn.canEat(false)) {
|
||||
playerIn.setActiveHand(hand);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
|
||||
} else {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import forestry.core.genetics.ItemResearchNote;
|
||||
public class ItemRegistryCore extends ItemRegistry {
|
||||
/* Fertilizer */
|
||||
public final ItemForestry fertilizerBio;
|
||||
public final ItemForestryBonemeal fertilizerCompound;
|
||||
public final ItemFertilizer fertilizerCompound;
|
||||
|
||||
/* Gems */
|
||||
public final ItemForestry apatite;
|
||||
@@ -87,7 +87,7 @@ public class ItemRegistryCore extends ItemRegistry {
|
||||
|
||||
public ItemRegistryCore() {
|
||||
fertilizerBio = registerItem(new ItemForestry(), "fertilizerBio");
|
||||
fertilizerCompound = registerItem(new ItemForestryBonemeal(), "fertilizerCompound");
|
||||
fertilizerCompound = registerItem(new ItemFertilizer(), "fertilizerCompound");
|
||||
|
||||
apatite = registerItem(new ItemForestry(), "apatite");
|
||||
OreDictionary.registerOre("gemApatite", apatite);
|
||||
|
||||
@@ -11,34 +11,32 @@
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools")
|
||||
public class ItemWrench extends ItemForestry implements IToolWrench {
|
||||
//@Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools")
|
||||
public class ItemWrench extends ItemForestry {//implements IToolWrench {
|
||||
|
||||
public ItemWrench() {
|
||||
setHarvestLevel("wrench", 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if (block.rotateBlock(world, pos, side)) {
|
||||
player.swingItem();
|
||||
return !world.isRemote;
|
||||
player.swingArm(hand);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean canWrench(EntityPlayer player, BlockPos pos) {
|
||||
return true;
|
||||
@@ -56,4 +54,5 @@ public class ItemWrench extends ItemForestry implements IToolWrench {
|
||||
@Override
|
||||
public void wrenchUsed(EntityPlayer entityPlayer, Entity entity) {
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -103,10 +103,6 @@ public class ModelManager implements IModelManager {
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerModels() {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
BlockColors blockColors = minecraft.getBlockColors();
|
||||
ItemColors itemColors = minecraft.getItemColors();
|
||||
|
||||
for (Block block : GameData.getBlockRegistry()) {
|
||||
if (block instanceof IItemModelRegister) {
|
||||
((IItemModelRegister) block).registerModel(Item.getItemFromBlock(block), getInstance());
|
||||
@@ -114,14 +110,30 @@ public class ModelManager implements IModelManager {
|
||||
if (block instanceof IStateMapperRegister) {
|
||||
((IStateMapperRegister) block).registerStateMapper();
|
||||
}
|
||||
if (block instanceof IBlockColor) {
|
||||
blockColors.registerBlockColorHandler((IBlockColor) block, block);
|
||||
}
|
||||
}
|
||||
for (Item item : GameData.getItemRegistry()) {
|
||||
if (item instanceof IItemModelRegister) {
|
||||
((IItemModelRegister) item).registerModel(item, getInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: keep lists of each type of block and item to be registered.
|
||||
* Iterating over GameData.getBlockRegistry() and GameData.getItemRegistry() will be VERY slow on a big pack.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerItemAndBlockColors() {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
BlockColors blockColors = minecraft.getBlockColors();
|
||||
ItemColors itemColors = minecraft.getItemColors();
|
||||
|
||||
for (Block block : GameData.getBlockRegistry()) {
|
||||
if (block instanceof IBlockColor) {
|
||||
blockColors.registerBlockColorHandler((IBlockColor) block, block);
|
||||
}
|
||||
}
|
||||
for (Item item : GameData.getItemRegistry()) {
|
||||
if (item instanceof IItemColor) {
|
||||
itemColors.registerItemColorHandler((IItemColor) item, item);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MultiblockUtil {
|
||||
List<IMultiblockComponent> neighborParts = new ArrayList<>();
|
||||
IChunkProvider chunkProvider = world.getChunkProvider();
|
||||
for (BlockPos neighbor : neighbors) {
|
||||
if (!chunkProvider.chunkExists(neighbor.getX() >> 4, neighbor.getZ() >> 4)) {
|
||||
if (chunkProvider.getLoadedChunk(neighbor.getX() >> 4, neighbor.getZ() >> 4) == null) {
|
||||
// Chunk not loaded, skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class MultiblockWorldRegistry {
|
||||
// These are blocks that exist in a valid chunk and require a controller
|
||||
for (IMultiblockComponent orphan : orphansToProcess) {
|
||||
coord = orphan.getCoordinates();
|
||||
if (!chunkProvider.chunkExists(coord.getX() >> 4, coord.getZ() >> 4)) {
|
||||
if (chunkProvider.getLoadedChunk(coord.getX() >> 4, coord.getZ() >> 4) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ public class MultiblockWorldRegistry {
|
||||
public void onPartAdded(IMultiblockComponent part) {
|
||||
BlockPos worldLocation = part.getCoordinates();
|
||||
|
||||
if (!worldObj.getChunkProvider().chunkExists(worldLocation.getX() >> 4, worldLocation.getZ() >> 4)) {
|
||||
if (worldObj.getChunkProvider().getLoadedChunk(worldLocation.getX() >> 4, worldLocation.getZ() >> 4) == null) {
|
||||
// Part goes into the waiting-for-chunk-load list
|
||||
Set<IMultiblockComponent> partSet;
|
||||
long chunkHash = ChunkCoordIntPair.chunkXZ2Int(worldLocation.getX() >> 4, worldLocation.getZ() >> 4);
|
||||
|
||||
@@ -42,14 +42,14 @@ public class PacketHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacket(ServerCustomPacketEvent event) {
|
||||
DataInputStreamForestry data = getStream(event.packet);
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer) event.handler).playerEntity;
|
||||
DataInputStreamForestry data = getStream(event.getPacket());
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer) event.getHandler()).playerEntity;
|
||||
|
||||
try {
|
||||
byte packetIdOrdinal = data.readByte();
|
||||
PacketIdServer packetId = PacketIdServer.VALUES[packetIdOrdinal];
|
||||
IForestryPacketServer packetHandler = packetId.getPacketHandler();
|
||||
checkThreadAndEnqueue(packetHandler, data, player, player.getServerForPlayer());
|
||||
checkThreadAndEnqueue(packetHandler, data, player, player.getServerWorld());
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to read packet.", e);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class PacketHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacket(ClientCustomPacketEvent event) {
|
||||
DataInputStreamForestry data = getStream(event.packet);
|
||||
DataInputStreamForestry data = getStream(event.getPacket());
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
|
||||
try {
|
||||
|
||||
@@ -106,6 +106,9 @@ public class ProxyRender {
|
||||
|
||||
public void registerModels() {
|
||||
}
|
||||
|
||||
public void registerItemAndBlockColors() {
|
||||
}
|
||||
|
||||
// public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){
|
||||
// return null;
|
||||
|
||||
@@ -192,8 +192,13 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
public void registerModels() {
|
||||
ModelManager.registerModels();
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@Override
|
||||
public void registerItemAndBlockColors() {
|
||||
ModelManager.registerItemAndBlockColors();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){
|
||||
// return Animation.INSTANCE.load(location, parameters);
|
||||
// }
|
||||
|
||||
@@ -15,10 +15,10 @@ public abstract class ForestryStateMapper implements IStateMapper {
|
||||
protected Map<IBlockState, ModelResourceLocation> mapStateModelLocations = Maps.newLinkedHashMap();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String getPropertyString(Map<IProperty, Comparable> map) {
|
||||
public String getPropertyString(Map<IProperty<?>, Comparable<?>> map) {
|
||||
StringBuilder stringbuilder = new StringBuilder();
|
||||
|
||||
for (Entry<IProperty, Comparable> entry : map.entrySet()) {
|
||||
for (Entry<IProperty<?>, Comparable<?>> entry : map.entrySet()) {
|
||||
if (stringbuilder.length() != 0) {
|
||||
stringbuilder.append(",");
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public class MachineStateMapper<T extends Enum<T> & IBlockType & IStringSerializ
|
||||
continue;
|
||||
}
|
||||
IBlockState state = block.getDefaultState().withProperty(META, type).withProperty(FACE, facing);
|
||||
LinkedHashMap<IProperty, Comparable> linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
|
||||
ResourceLocation blockLocation = Block.blockRegistry.getNameForObject(block);
|
||||
LinkedHashMap<IProperty<?>, Comparable<?>> linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
|
||||
ResourceLocation blockLocation = Block.REGISTRY.getNameForObject(block);
|
||||
String s = String.format("%s:%s", blockLocation.getResourceDomain(), blockLocation.getResourcePath() + "_" + META.getName((T) linkedhashmap.remove(META)));
|
||||
mapStateModelLocations.put(state, new ModelResourceLocation(s, getPropertyString(linkedhashmap)));
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer<TileAnalyzer> {
|
||||
}
|
||||
RenderManager rendermanager = Proxies.common.getClientInstance().getRenderManager();
|
||||
|
||||
rendermanager.renderEntityWithPosYaw(dummyEntityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
rendermanager.doRenderEntity(dummyEntityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F, false);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.core.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -31,7 +30,6 @@ import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
|
||||
@@ -52,13 +50,8 @@ import forestry.core.network.packets.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import buildcraft.api.statements.ITriggerInternal;
|
||||
import buildcraft.api.statements.ITriggerProvider;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public abstract class TileForestry extends TileEntity implements IStreamable, IErrorLogicSource, ITriggerProvider, ISidedInventory, IFilterSlotDelegate, IRestrictedAccess, ITitled, ILocatable, IGuiHandlerTile, ITickable {
|
||||
//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public abstract class TileForestry extends TileEntity implements IStreamable, IErrorLogicSource, ISidedInventory, IFilterSlotDelegate, IRestrictedAccess, ITitled, ILocatable, IGuiHandlerTile, ITickable {
|
||||
private static final EnumFacing[] forgeDirections = EnumFacing.values();
|
||||
private static final Random rand = new Random();
|
||||
|
||||
@@ -199,17 +192,18 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE
|
||||
}
|
||||
|
||||
/* ITriggerProvider */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
return null;
|
||||
}
|
||||
// TODO: buildcraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// / REDSTONE INFO
|
||||
protected boolean isRedstoneActivated() {
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.io.IOException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.circuits.ISpeedUpgradable;
|
||||
import forestry.core.config.Config;
|
||||
@@ -27,11 +25,10 @@ import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.render.TankRenderInfo;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import buildcraft.api.tiles.IHasWork;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles")
|
||||
public abstract class TilePowered extends TileBase implements IRenderableTile, IEnergyReceiver, IPowerHandler, IHasWork, ISpeedUpgradable, IStreamableGui {
|
||||
//@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles")
|
||||
public abstract class TilePowered extends TileBase implements IRenderableTile, IEnergyReceiver, IPowerHandler, ISpeedUpgradable, IStreamableGui {
|
||||
private static final int WORK_TICK_INTERVAL = 5; // one Forestry work tick happens every WORK_TICK_INTERVAL game ticks
|
||||
|
||||
private final EnergyManager energyManager;
|
||||
@@ -89,7 +86,8 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO: buildcraft for 1.9
|
||||
// @Override
|
||||
public abstract boolean hasWork();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,74 +10,62 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.triggers;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
// TODO: buildcraft for 1.9
|
||||
public abstract class Trigger {//implements ITriggerExternal {
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
// private final String uid;
|
||||
// private final String localization;
|
||||
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import buildcraft.api.statements.StatementManager;
|
||||
|
||||
public abstract class Trigger implements ITriggerExternal {
|
||||
|
||||
private final String uid;
|
||||
private final String localization;
|
||||
|
||||
protected Trigger(String uid) {
|
||||
this(uid, uid);
|
||||
}
|
||||
|
||||
protected Trigger(String uid, String localization) {
|
||||
this.uid = "forestry:" + uid;
|
||||
this.localization = localization;
|
||||
StatementManager.registerStatement(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Translator.translateToLocal("for.trigger." + localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatementParameter createParameter(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxParameters() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minParameters() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private TextureAtlasSprite icon;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites() {
|
||||
icon = TextureManager.registerSprite("triggers/" + localization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getGuiSprite() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatement rotateLeft() {
|
||||
return this;
|
||||
}
|
||||
// protected Trigger(String uid) {
|
||||
// this(uid, uid);
|
||||
// }
|
||||
//
|
||||
// protected Trigger(String uid, String localization) {
|
||||
// this.uid = "forestry:" + uid;
|
||||
// this.localization = localization;
|
||||
// StatementManager.registerStatement(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUniqueTag() {
|
||||
// return uid;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return Translator.translateToLocal("for.trigger." + localization);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IStatementParameter createParameter(int index) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int maxParameters() {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int minParameters() {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// private TextureAtlasSprite icon;
|
||||
//
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerSprites() {
|
||||
// icon = TextureManager.registerSprite("triggers/" + localization);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public TextureAtlasSprite getGuiSprite() {
|
||||
// return icon;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IStatement rotateLeft() {
|
||||
// return this;
|
||||
// }
|
||||
}
|
||||
@@ -10,11 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.utils;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -23,13 +19,11 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@@ -41,13 +35,10 @@ import forestry.core.inventory.filters.StandardStackFilters;
|
||||
import forestry.core.inventory.iterators.IExtInvSlot;
|
||||
import forestry.core.inventory.iterators.InventoryIterator;
|
||||
import forestry.core.inventory.manipulators.InventoryManipulator;
|
||||
import forestry.core.inventory.wrappers.InventoryCopy;
|
||||
import forestry.core.inventory.wrappers.SidedInventoryMapper;
|
||||
import forestry.core.tiles.AdjacentTileCache;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
public abstract class InventoryUtil {
|
||||
|
||||
public static IInventory getInventory(IInventory inv, EnumFacing side) {
|
||||
@@ -286,42 +277,43 @@ public abstract class InventoryUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO Buildcraft for 1.9
|
||||
@Optional.Method(modid = "BuildCraftAPI|transport")
|
||||
private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache, EnumFacing[] directions) {
|
||||
IInventory invClone = new InventoryCopy(source);
|
||||
ItemStack stackToMove = removeOneItem(invClone);
|
||||
if (stackToMove == null) {
|
||||
return false;
|
||||
}
|
||||
if (stackToMove.stackSize <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Map.Entry<EnumFacing, IPipeTile>> pipes = new ArrayList<>();
|
||||
boolean foundPipe = false;
|
||||
for (EnumFacing side : directions) {
|
||||
TileEntity tile = tileCache.getTileOnSide(side);
|
||||
if (tile instanceof IPipeTile) {
|
||||
IPipeTile pipe = (IPipeTile) tile;
|
||||
if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) {
|
||||
pipes.add(new AbstractMap.SimpleEntry<>(side, pipe));
|
||||
foundPipe = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPipe) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int choice = tileCache.getSource().getWorld().rand.nextInt(pipes.size());
|
||||
Map.Entry<EnumFacing, IPipeTile> pipe = pipes.get(choice);
|
||||
if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite(), null) > 0) {
|
||||
if (removeOneItem(source, stackToMove) != null) {
|
||||
pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite(), null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// IInventory invClone = new InventoryCopy(source);
|
||||
// ItemStack stackToMove = removeOneItem(invClone);
|
||||
// if (stackToMove == null) {
|
||||
// return false;
|
||||
// }
|
||||
// if (stackToMove.stackSize <= 0) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// List<Map.Entry<EnumFacing, IPipeTile>> pipes = new ArrayList<>();
|
||||
// boolean foundPipe = false;
|
||||
// for (EnumFacing side : directions) {
|
||||
// TileEntity tile = tileCache.getTileOnSide(side);
|
||||
// if (tile instanceof IPipeTile) {
|
||||
// IPipeTile pipe = (IPipeTile) tile;
|
||||
// if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) {
|
||||
// pipes.add(new AbstractMap.SimpleEntry<>(side, pipe));
|
||||
// foundPipe = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!foundPipe) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// int choice = tileCache.getSource().getWorld().rand.nextInt(pipes.size());
|
||||
// Map.Entry<EnumFacing, IPipeTile> pipe = pipes.get(choice);
|
||||
// if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite(), null) > 0) {
|
||||
// if (removeOneItem(source, stackToMove) != null) {
|
||||
// pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite(), null);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -628,19 +620,11 @@ public abstract class InventoryUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack container = itemstack.getItem().getContainerItem(itemstack);
|
||||
|
||||
if (container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
|
||||
if (player != null) {
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
|
||||
}
|
||||
container = null;
|
||||
}
|
||||
|
||||
ItemStack container = ForgeHooks.getContainerItem(itemstack);
|
||||
if (container != null) {
|
||||
if (!tryAddStack(stowing, container, slotIndex, 1, true)) {
|
||||
if (!tryAddStack(stowing, container, true) && player != null) {
|
||||
player.dropPlayerItemWithRandomChoice(container, true);
|
||||
player.dropItem(container, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,12 +34,11 @@ public class ContainerGenerator extends ContainerLiquidTanks<TileEuGenerator> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (Object crafter : crafters) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
for (ICrafting crafter : listeners) {
|
||||
tile.sendGUINetworkData(this, crafter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import forestry.core.gui.widgets.SocketWidget;
|
||||
import forestry.core.render.EnumTankLevel;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
|
||||
// TODO: IC2 for 1.9
|
||||
public class GuiEngineElectric extends GuiEngine<ContainerEngineElectric, TileEngineElectric> {
|
||||
|
||||
public GuiEngineElectric(InventoryPlayer inventory, TileEngineElectric tile) {
|
||||
@@ -24,23 +25,23 @@ public class GuiEngineElectric extends GuiEngine<ContainerEngineElectric, TileEn
|
||||
widgetManager.add(new SocketWidget(this.widgetManager, 30, 40, tile, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
TileEngineElectric engine = inventory;
|
||||
int storageHeight = engine.getStorageScaled(46);
|
||||
int storageMaxHeight = engine.getStorageScaled(100);
|
||||
EnumTankLevel rated = EnumTankLevel.rateTankLevel(storageMaxHeight);
|
||||
|
||||
drawHealthMeter(guiLeft + 74, guiTop + 25, storageHeight, rated);
|
||||
}
|
||||
|
||||
private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) {
|
||||
int i = 176 + rated.getLevelScaled(16);
|
||||
int k = 0;
|
||||
|
||||
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
|
||||
}
|
||||
// @Override
|
||||
// protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
// super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
//
|
||||
// TileEngineElectric engine = inventory;
|
||||
// int storageHeight = engine.getStorageScaled(46);
|
||||
// int storageMaxHeight = engine.getStorageScaled(100);
|
||||
// EnumTankLevel rated = EnumTankLevel.rateTankLevel(storageMaxHeight);
|
||||
//
|
||||
// drawHealthMeter(guiLeft + 74, guiTop + 25, storageHeight, rated);
|
||||
// }
|
||||
//
|
||||
// private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) {
|
||||
// int i = 176 + rated.getLevelScaled(16);
|
||||
// int k = 0;
|
||||
//
|
||||
// this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.energy.tiles.TileEuGenerator;
|
||||
|
||||
// TODO: IC2 for 1.9
|
||||
public class GuiGenerator extends GuiForestryTitled<ContainerGenerator, TileEuGenerator> {
|
||||
|
||||
public GuiGenerator(InventoryPlayer inventory, TileEuGenerator tile) {
|
||||
@@ -24,14 +25,14 @@ public class GuiGenerator extends GuiForestryTitled<ContainerGenerator, TileEuGe
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 49, 17, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
int progress = inventory.getStoredScaled(49);
|
||||
if (progress > 0) {
|
||||
drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18);
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
// super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
//
|
||||
// int progress = inventory.getStoredScaled(49);
|
||||
// if (progress > 0) {
|
||||
// drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -15,8 +15,7 @@ import net.minecraft.item.ItemStack;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
|
||||
// TODO: IC2 for 1.9
|
||||
public class InventoryEngineElectric extends InventoryAdapterTile<TileEngineElectric> {
|
||||
public static final short SLOT_BATTERY = 0;
|
||||
|
||||
@@ -26,9 +25,9 @@ public class InventoryEngineElectric extends InventoryAdapterTile<TileEngineElec
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_BATTERY) {
|
||||
return ElectricItem.manager.getCharge(itemStack) > 0;
|
||||
}
|
||||
// if (slotIndex == SLOT_BATTERY) {
|
||||
// return ElectricItem.manager.getCharge(itemStack) > 0;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
@@ -41,10 +42,9 @@ public class TileEngineClockwork extends TileEngine {
|
||||
public TileEngineClockwork() {
|
||||
super(null, ENGINE_CLOCKWORK_HEAT_MAX, 10000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
|
||||
public void openGui(EntityPlayer player, ItemStack heldItem) {
|
||||
if (!(player instanceof EntityPlayerMP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import forestry.api.circuits.ICircuitSocketType;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
@@ -36,10 +35,8 @@ import forestry.core.tiles.TileEngine;
|
||||
import forestry.energy.gui.ContainerEngineElectric;
|
||||
import forestry.energy.gui.GuiEngineElectric;
|
||||
import forestry.energy.inventory.InventoryEngineElectric;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
|
||||
// TODO: IC2 for 1.9
|
||||
public class TileEngineElectric extends TileEngine implements ISocketable, IInventory, IStreamableGui {
|
||||
protected static class EuConfig {
|
||||
|
||||
@@ -57,16 +54,16 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
|
||||
private final EuConfig euConfig = new EuConfig();
|
||||
|
||||
private BasicSink ic2EnergySink;
|
||||
// private BasicSink ic2EnergySink;
|
||||
|
||||
public TileEngineElectric() {
|
||||
super("engine.tin", Constants.ENGINE_ELECTRIC_HEAT_MAX, 100000);
|
||||
|
||||
setInternalInventory(new InventoryEngineElectric(this));
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) {
|
||||
ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
|
||||
}
|
||||
// if (PluginIC2.instance.isAvailable()) {
|
||||
// ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
|
||||
// }
|
||||
}
|
||||
|
||||
// / SAVING / LOADING
|
||||
@@ -74,9 +71,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.readFromNBT(nbttagcompound);
|
||||
}
|
||||
// if (ic2EnergySink != null) {
|
||||
// ic2EnergySink.readFromNBT(nbttagcompound);
|
||||
// }
|
||||
sockets.readFromNBT(nbttagcompound);
|
||||
|
||||
ItemStack chip = sockets.getStackInSlot(0);
|
||||
@@ -92,26 +89,26 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.writeToNBT(nbttagcompound);
|
||||
}
|
||||
// if (ic2EnergySink != null) {
|
||||
// ic2EnergySink.writeToNBT(nbttagcompound);
|
||||
// }
|
||||
sockets.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.onChunkUnload();
|
||||
}
|
||||
// if (ic2EnergySink != null) {
|
||||
// ic2EnergySink.onChunkUnload();
|
||||
// }
|
||||
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.invalidate();
|
||||
}
|
||||
// if (ic2EnergySink != null) {
|
||||
// ic2EnergySink.invalidate();
|
||||
// }
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
@@ -159,11 +156,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
// No work to be done if IC2 is unavailable.
|
||||
if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ic2EnergySink.update();
|
||||
// if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ic2EnergySink.update();
|
||||
|
||||
super.updateServerSide();
|
||||
|
||||
@@ -180,8 +177,8 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
return;
|
||||
}
|
||||
|
||||
boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
|
||||
errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
|
||||
// boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
|
||||
// errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,10 +190,10 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
return;
|
||||
}
|
||||
|
||||
if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
|
||||
currentOutput = euConfig.rfPerCycle;
|
||||
energyManager.generateEnergy(euConfig.rfPerCycle);
|
||||
}
|
||||
// if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
|
||||
// currentOutput = euConfig.rfPerCycle;
|
||||
// energyManager.generateEnergy(euConfig.rfPerCycle);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -205,22 +202,23 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
return;
|
||||
}
|
||||
|
||||
ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3);
|
||||
// ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3);
|
||||
}
|
||||
|
||||
// / STATE INFORMATION
|
||||
@Override
|
||||
protected boolean isBurning() {
|
||||
return mayBurn() && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle);
|
||||
// TODO: IC2 for 1.9
|
||||
return mayBurn();// && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle);
|
||||
}
|
||||
|
||||
public int getStorageScaled(int i) {
|
||||
if (ic2EnergySink == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity());
|
||||
}
|
||||
// public int getStorageScaled(int i) {
|
||||
// if (ic2EnergySink == null) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity());
|
||||
// }
|
||||
|
||||
// / SMP GUI
|
||||
@Override
|
||||
@@ -229,11 +227,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
data.writeVarInt(heat);
|
||||
sockets.writeData(data);
|
||||
energyManager.writeData(data);
|
||||
final boolean hasIc2EnergySink = (ic2EnergySink != null);
|
||||
data.writeBoolean(hasIc2EnergySink);
|
||||
if (hasIc2EnergySink) {
|
||||
data.writeVarInt((int) ic2EnergySink.getEnergyStored());
|
||||
}
|
||||
// final boolean hasIc2EnergySink = (ic2EnergySink != null);
|
||||
// data.writeBoolean(hasIc2EnergySink);
|
||||
// if (hasIc2EnergySink) {
|
||||
// data.writeVarInt((int) ic2EnergySink.getEnergyStored());
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,11 +240,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
heat = data.readVarInt();
|
||||
sockets.readData(data);
|
||||
energyManager.readData(data);
|
||||
final boolean hasIc2EnergySink = data.readBoolean();
|
||||
if (hasIc2EnergySink) {
|
||||
final int energyStored = data.readVarInt();
|
||||
ic2EnergySink.setEnergyStored(energyStored);
|
||||
}
|
||||
// final boolean hasIc2EnergySink = data.readBoolean();
|
||||
// if (hasIc2EnergySink) {
|
||||
// final int energyStored = data.readVarInt();
|
||||
// ic2EnergySink.setEnergyStored(energyStored);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -265,9 +263,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
|
||||
euConfig.rfPerCycle += rfChange;
|
||||
euConfig.euStorage += storageChange;
|
||||
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.setCapacity(euConfig.euStorage);
|
||||
}
|
||||
// if (ic2EnergySink != null) {
|
||||
// ic2EnergySink.setCapacity(euConfig.euStorage);
|
||||
// }
|
||||
}
|
||||
|
||||
/* ISocketable */
|
||||
|
||||
@@ -42,8 +42,6 @@ import forestry.energy.gui.GuiEnginePeat;
|
||||
import forestry.energy.inventory.InventoryEnginePeat;
|
||||
import forestry.factory.triggers.FactoryTriggers;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public class TileEnginePeat extends TileEngine implements ISidedInventory {
|
||||
private Item fuelItem;
|
||||
private int fuelItemMeta;
|
||||
@@ -331,14 +329,15 @@ public class TileEnginePeat extends TileEngine implements ISidedInventory {
|
||||
}
|
||||
|
||||
/* ITriggerProvider */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
res.add(FactoryTriggers.lowFuel25);
|
||||
res.add(FactoryTriggers.lowFuel10);
|
||||
return res;
|
||||
}
|
||||
// TODO: buildcraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
// res.add(FactoryTriggers.lowFuel25);
|
||||
// res.add(FactoryTriggers.lowFuel10);
|
||||
// return res;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.GeneratorFuel;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
@@ -41,10 +40,8 @@ import forestry.core.tiles.TileBase;
|
||||
import forestry.energy.gui.ContainerGenerator;
|
||||
import forestry.energy.gui.GuiGenerator;
|
||||
import forestry.energy.inventory.InventoryGenerator;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSource;
|
||||
|
||||
// TODO: IC2 for 1.9
|
||||
public class TileEuGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IFluidHandler, IRenderableTile {
|
||||
private static final int maxEnergy = 30000;
|
||||
|
||||
@@ -53,7 +50,7 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
private int tickCount = 0;
|
||||
|
||||
private BasicSource ic2EnergySource;
|
||||
// private BasicSource ic2EnergySource;
|
||||
|
||||
public TileEuGenerator() {
|
||||
super("generator");
|
||||
@@ -63,18 +60,18 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet());
|
||||
tankManager = new TankManager(this, resourceTank);
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) {
|
||||
ic2EnergySource = new BasicSource(this, maxEnergy, 1);
|
||||
}
|
||||
// if (PluginIC2.instance.isAvailable()) {
|
||||
// ic2EnergySource = new BasicSource(this, maxEnergy, 1);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
}
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
// }
|
||||
|
||||
tankManager.writeToNBT(nbttagcompound);
|
||||
}
|
||||
@@ -83,9 +80,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
}
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
// }
|
||||
|
||||
tankManager.readFromNBT(nbttagcompound);
|
||||
}
|
||||
@@ -104,18 +101,18 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.onChunkUnload();
|
||||
}
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.onChunkUnload();
|
||||
// }
|
||||
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.invalidate();
|
||||
}
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.invalidate();
|
||||
// }
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
@@ -129,25 +126,25 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
// No work to be done if IC2 is unavailable.
|
||||
if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ic2EnergySource.update();
|
||||
|
||||
if (resourceTank.getFluidAmount() > 0) {
|
||||
GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid());
|
||||
if (resourceTank.canDrain(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) {
|
||||
ic2EnergySource.addEnergy(fuel.eu);
|
||||
this.tickCount++;
|
||||
|
||||
if (tickCount >= fuel.rate) {
|
||||
tickCount = 0;
|
||||
resourceTank.drain(fuel.fuelConsumed.amount, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ic2EnergySource.update();
|
||||
//
|
||||
// if (resourceTank.getFluidAmount() > 0) {
|
||||
// GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid());
|
||||
// if (resourceTank.canDrain(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) {
|
||||
// ic2EnergySource.addEnergy(fuel.eu);
|
||||
// this.tickCount++;
|
||||
//
|
||||
// if (tickCount >= fuel.rate) {
|
||||
// tickCount = 0;
|
||||
// resourceTank.drain(fuel.fuelConsumed.amount, true);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
boolean hasFuel = resourceTank.getFluidAmount() > 0;
|
||||
errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
|
||||
@@ -161,13 +158,13 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
return (resourceTank.getFluidAmount() * i) / Constants.PROCESSOR_TANK_CAPACITY;
|
||||
}
|
||||
|
||||
public int getStoredScaled(int i) {
|
||||
if (ic2EnergySource == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy;
|
||||
}
|
||||
// public int getStoredScaled(int i) {
|
||||
// if (ic2EnergySource == null) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public TankRenderInfo getResourceTankInfo() {
|
||||
@@ -182,16 +179,16 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
if (i == 0) {
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.setEnergyStored(j);
|
||||
}
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.setEnergyStored(j);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
if (ic2EnergySource != null) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored());
|
||||
}
|
||||
// if (ic2EnergySource != null) {
|
||||
// iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored());
|
||||
// }
|
||||
}
|
||||
|
||||
/* ILiquidTankTile */
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ContainerFabricator extends ContainerLiquidTanks<TileFabricator> im
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (ICrafting crafter : crafters) {
|
||||
for (ICrafting crafter : listeners) {
|
||||
tile.sendGUINetworkData(this, crafter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ContainerFermenter extends ContainerLiquidTanks<TileFermenter> {
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (ICrafting crafter : crafters) {
|
||||
for (ICrafting crafter : listeners) {
|
||||
tile.sendGUINetworkData(this, crafter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ContainerMoistener extends ContainerLiquidTanks<TileMoistener> impl
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (ICrafting crafter : crafters) {
|
||||
for (ICrafting crafter : listeners) {
|
||||
tile.sendGUINetworkData(this, crafter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ContainerRaintank extends ContainerLiquidTanks<TileRaintank> {
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (ICrafting crafter : crafters) {
|
||||
for (ICrafting crafter : listeners) {
|
||||
tile.sendGUINetworkData(this, crafter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,21 +11,17 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -43,9 +39,6 @@ import forestry.factory.gui.ContainerBottler;
|
||||
import forestry.factory.gui.GuiBottler;
|
||||
import forestry.factory.inventory.InventoryBottler;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
import forestry.factory.triggers.FactoryTriggers;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public class TileBottler extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler {
|
||||
private static final int TICKS_PER_RECIPE_TIME = 5;
|
||||
@@ -197,14 +190,15 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
res.add(FactoryTriggers.lowResource25);
|
||||
res.add(FactoryTriggers.lowResource10);
|
||||
return res;
|
||||
}
|
||||
// TODO: BuildCraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
// res.add(FactoryTriggers.lowResource25);
|
||||
// res.add(FactoryTriggers.lowResource10);
|
||||
// return res;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.factory.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -20,10 +19,6 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.CircuitSocketType;
|
||||
@@ -44,9 +39,6 @@ import forestry.factory.gui.ContainerCentrifuge;
|
||||
import forestry.factory.gui.GuiCentrifuge;
|
||||
import forestry.factory.inventory.InventoryCentrifuge;
|
||||
import forestry.factory.recipes.CentrifugeRecipeManager;
|
||||
import forestry.factory.triggers.FactoryTriggers;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public class TileCentrifuge extends TilePowered implements ISocketable, ISidedInventory {
|
||||
private static final int TICKS_PER_RECIPE_TIME = 1;
|
||||
@@ -196,14 +188,15 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
res.add(FactoryTriggers.lowResource25);
|
||||
res.add(FactoryTriggers.lowResource10);
|
||||
return res;
|
||||
}
|
||||
// TODO: BuildCraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
// res.add(FactoryTriggers.lowResource25);
|
||||
// res.add(FactoryTriggers.lowResource10);
|
||||
// return res;
|
||||
// }
|
||||
|
||||
/* ISocketable */
|
||||
@Override
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -20,14 +18,12 @@ import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
@@ -49,9 +45,6 @@ import forestry.factory.gui.ContainerFermenter;
|
||||
import forestry.factory.gui.GuiFermenter;
|
||||
import forestry.factory.inventory.InventoryFermenter;
|
||||
import forestry.factory.recipes.FermenterRecipeManager;
|
||||
import forestry.factory.triggers.FactoryTriggers;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public class TileFermenter extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler {
|
||||
private final FilteredTank resourceTank;
|
||||
@@ -331,14 +324,15 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
res.add(FactoryTriggers.lowResource25);
|
||||
res.add(FactoryTriggers.lowResource10);
|
||||
return res;
|
||||
}
|
||||
// TODO: BuildCraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// LinkedList<ITriggerExternal> res = new LinkedList<>();
|
||||
// res.add(FactoryTriggers.lowResource25);
|
||||
// res.add(FactoryTriggers.lowResource10);
|
||||
// return res;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
|
||||
@@ -10,46 +10,39 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.triggers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import forestry.core.tiles.TilePowered;
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: BuildCraft for 1.9
|
||||
public class TriggerLowFuel extends Trigger {
|
||||
|
||||
private float threshold = 0.25F;
|
||||
|
||||
public TriggerLowFuel(String uid, float threshold) {
|
||||
super(uid, "lowFuel");
|
||||
// super(uid, "lowFuel");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
|
||||
if (tile instanceof TilePowered) {
|
||||
return !((TilePowered) tile).hasFuelMin(threshold);
|
||||
}
|
||||
|
||||
if (tile instanceof TileEngine) {
|
||||
TileEngine tileEngine = (TileEngine) tile;
|
||||
return !tileEngine.hasFuelMin(threshold);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
//
|
||||
// if (tile instanceof TilePowered) {
|
||||
// return !((TilePowered) tile).hasFuelMin(threshold);
|
||||
// }
|
||||
//
|
||||
// if (tile instanceof TileEngine) {
|
||||
// TileEngine tileEngine = (TileEngine) tile;
|
||||
// return !tileEngine.hasFuelMin(threshold);
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -10,39 +10,33 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.triggers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.core.tiles.TilePowered;
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: BuildCraft for 1.9
|
||||
public class TriggerLowResource extends Trigger {
|
||||
|
||||
private float threshold = 0.25F;
|
||||
|
||||
public TriggerLowResource(String tag, float threshold) {
|
||||
super(tag, "lowResources");
|
||||
// super(tag, "lowResources");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TilePowered)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !((TilePowered) tile).hasResourcesMin(threshold);
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// if (!(tile instanceof TilePowered)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return !((TilePowered) tile).hasResourcesMin(threshold);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package forestry.farming.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockBush;
|
||||
@@ -49,7 +50,7 @@ public class BlockMushroom extends BlockBush implements IItemModelRegister, IGro
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,81 +1,68 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
import ic2.api.crops.ICropTile;
|
||||
|
||||
public class CropBasicIC2Crop extends Crop {
|
||||
private final TileEntity tileEntity;
|
||||
|
||||
public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) {
|
||||
super(world, position);
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
return canHarvestCrop(this.tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
return getCropDrops(this.tileEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is an instance of ICropTile.
|
||||
* @param tileEntity tile entity to be checked.
|
||||
* @return true if there is an IC2 crop and false otherwise.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
public static boolean isIC2Crop(TileEntity tileEntity) {
|
||||
if (tileEntity instanceof ICropTile) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an IC2 crop is ready to be harvested.
|
||||
* @param tileEntity tile entity to be checked.
|
||||
* @return true if crop size is optimal for harvest and false otherwise.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
public static boolean canHarvestCrop(TileEntity tileEntity) {
|
||||
if (isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
if (crop.getCrop() == null) {
|
||||
return false;
|
||||
}
|
||||
if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes care of everything related to the harvesting of the
|
||||
* crop meaning it will calculate the drops and also do setSizeAfterHarvest().
|
||||
* @param tileEntity tile entity to be checked.
|
||||
* @return list containing the drops.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
private static List<ItemStack> getCropDrops(TileEntity tileEntity) {
|
||||
if (isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
return crop.performHarvest();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// TODO: IC2 for 1.9
|
||||
public class CropBasicIC2Crop {//extends Crop {
|
||||
// private final TileEntity tileEntity;
|
||||
//
|
||||
// public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) {
|
||||
// super(world, position);
|
||||
// this.tileEntity = tileEntity;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean isCrop(Vect pos) {
|
||||
// return canHarvestCrop(this.tileEntity);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
// return getCropDrops(this.tileEntity);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if there is an instance of ICropTile.
|
||||
// * @param tileEntity tile entity to be checked.
|
||||
// * @return true if there is an IC2 crop and false otherwise.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// public static boolean isIC2Crop(TileEntity tileEntity) {
|
||||
// if (tileEntity instanceof ICropTile) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if an IC2 crop is ready to be harvested.
|
||||
// * @param tileEntity tile entity to be checked.
|
||||
// * @return true if crop size is optimal for harvest and false otherwise.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// public static boolean canHarvestCrop(TileEntity tileEntity) {
|
||||
// if (isIC2Crop(tileEntity)) {
|
||||
// ICropTile crop = (ICropTile) tileEntity;
|
||||
// if (crop.getCrop() == null) {
|
||||
// return false;
|
||||
// }
|
||||
// if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * This function takes care of everything related to the harvesting of the
|
||||
// * crop meaning it will calculate the drops and also do setSizeAfterHarvest().
|
||||
// * @param tileEntity tile entity to be checked.
|
||||
// * @return list containing the drops.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// private static List<ItemStack> getCropDrops(TileEntity tileEntity) {
|
||||
// if (isIC2Crop(tileEntity)) {
|
||||
// ICropTile crop = (ICropTile) tileEntity;
|
||||
// return crop.performHarvest();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
@@ -13,6 +13,7 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -79,7 +80,8 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
|
||||
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(pos, direction, i);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getWorld(), position)) {
|
||||
IBlockState state = world.getBlockState(position);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -89,7 +90,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
|
||||
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(pos, direction, i);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) {
|
||||
IBlockState state = world.getBlockState(position);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -89,7 +90,8 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
|
||||
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(pos, direction, i);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) {
|
||||
IBlockState blockState = world.getBlockState(position);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(blockState, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +1,68 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
// TODO: IC2 for 1.9
|
||||
public class FarmableBasicIC2Crop {//implements IFarmable {
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
import ic2.api.crops.ICropTile;
|
||||
|
||||
public class FarmableBasicIC2Crop implements IFarmable {
|
||||
|
||||
/**
|
||||
* Perform some of the actions of the crop-matron.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
public static void babysitCrop(TileEntity tileEntity) {
|
||||
if (CropBasicIC2Crop.isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
/*
|
||||
This part might be unbalanced until a custom farm logic is added and makes use of weed-ex.
|
||||
if (crop.getCrop() != null) {
|
||||
if (crop.getCrop().isWeed(crop)) {
|
||||
crop.reset();
|
||||
}
|
||||
}*/
|
||||
if (crop.getStorageWater() <= 200) {
|
||||
crop.setStorageWater(200);
|
||||
}
|
||||
if (crop.getStorageNutrient() <= 100) {
|
||||
crop.setStorageNutrient(crop.getStorageNutrient() + 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
TileEntity crop = world.getTileEntity(pos);
|
||||
if (CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
babysitCrop(crop);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICrop getCropAt(World world, BlockPos pos) {
|
||||
TileEntity crop = world.getTileEntity(pos);
|
||||
if (crop == null) {
|
||||
return null;
|
||||
}
|
||||
if (!CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
return null;
|
||||
}
|
||||
if (!CropBasicIC2Crop.canHarvestCrop(crop)) {
|
||||
return null;
|
||||
}
|
||||
return new CropBasicIC2Crop(world, crop, new Vect(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
// /**
|
||||
// * Perform some of the actions of the crop-matron.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// public static void babysitCrop(TileEntity tileEntity) {
|
||||
// if (CropBasicIC2Crop.isIC2Crop(tileEntity)) {
|
||||
// ICropTile crop = (ICropTile) tileEntity;
|
||||
// /*
|
||||
// This part might be unbalanced until a custom farm logic is added and makes use of weed-ex.
|
||||
// if (crop.getCrop() != null) {
|
||||
// if (crop.getCrop().isWeed(crop)) {
|
||||
// crop.reset();
|
||||
// }
|
||||
// }*/
|
||||
// if (crop.getStorageWater() <= 200) {
|
||||
// crop.setStorageWater(200);
|
||||
// }
|
||||
// if (crop.getStorageNutrient() <= 100) {
|
||||
// crop.setStorageNutrient(crop.getStorageNutrient() + 100);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
// TileEntity crop = world.getTileEntity(pos);
|
||||
// if (CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
// babysitCrop(crop);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ICrop getCropAt(World world, BlockPos pos) {
|
||||
// TileEntity crop = world.getTileEntity(pos);
|
||||
// if (crop == null) {
|
||||
// return null;
|
||||
// }
|
||||
// if (!CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
// return null;
|
||||
// }
|
||||
// if (!CropBasicIC2Crop.canHarvestCrop(crop)) {
|
||||
// return null;
|
||||
// }
|
||||
// return new CropBasicIC2Crop(world, crop, new Vect(pos));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isGermling(ItemStack itemstack) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isWindfall(ItemStack itemstack) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
@@ -13,6 +13,8 @@ package forestry.farming.logic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -51,7 +53,7 @@ public class FarmableGE implements IFarmable {
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,8 @@ package forestry.farming.logic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -68,7 +70,7 @@ public class FarmableGenericCrop implements IFarmable {
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,8 @@ package forestry.farming.logic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -90,7 +92,7 @@ public class FarmableGenericSapling implements IFarmable {
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class FarmableVanillaMushroom extends FarmableGenericSapling {
|
||||
public ICrop getCropAt(World world, BlockPos pos) {
|
||||
Block block = BlockUtil.getBlock(world, pos);
|
||||
|
||||
if (block != Blocks.BROWN_MUSHROOM_block && block != Blocks.RED_MUSHROOM_block) {
|
||||
if (block != Blocks.BROWN_MUSHROOM_BLOCK && block != Blocks.RED_MUSHROOM_BLOCK) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -41,7 +43,7 @@ public class FarmableVanillaSapling extends FarmableGenericSapling {
|
||||
|
||||
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), pos);
|
||||
} else {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,29 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.tiles;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.multiblock.IFarmComponent;
|
||||
import forestry.core.inventory.AdjacentInventoryCache;
|
||||
import forestry.core.tiles.AdjacentTileCache;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.triggers.FarmingTriggers;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import buildcraft.api.statements.ITriggerInternal;
|
||||
import buildcraft.api.statements.ITriggerProvider;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active, ITriggerProvider {
|
||||
// TODO: Buildcraft for 1.9
|
||||
//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active {
|
||||
|
||||
private static final EnumFacing[] dumpDirections = new EnumFacing[]{EnumFacing.DOWN};
|
||||
|
||||
@@ -70,21 +60,22 @@ public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmCom
|
||||
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
if (!getMultiblockLogic().isConnected()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return FarmingTriggers.allExternalTriggers;
|
||||
}
|
||||
// TODO: Buildcraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
//
|
||||
// /* ITRIGGERPROVIDER */
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// if (!getMultiblockLogic().isConnected()) {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
//
|
||||
// return FarmingTriggers.allExternalTriggers;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -10,36 +10,30 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class FarmingTriggers {
|
||||
public static Trigger lowResourceLiquid50;
|
||||
public static Trigger lowResourceLiquid25;
|
||||
public static Trigger lowSoil128;
|
||||
public static Trigger lowSoil64;
|
||||
public static Trigger lowSoil32;
|
||||
public static Trigger lowFertilizer50;
|
||||
public static Trigger lowFertilizer25;
|
||||
public static Trigger lowGermlings25;
|
||||
public static Trigger lowGermlings10;
|
||||
public static List<ITriggerExternal> allExternalTriggers;
|
||||
// public static Trigger lowResourceLiquid50;
|
||||
// public static Trigger lowResourceLiquid25;
|
||||
// public static Trigger lowSoil128;
|
||||
// public static Trigger lowSoil64;
|
||||
// public static Trigger lowSoil32;
|
||||
// public static Trigger lowFertilizer50;
|
||||
// public static Trigger lowFertilizer25;
|
||||
// public static Trigger lowGermlings25;
|
||||
// public static Trigger lowGermlings10;
|
||||
// public static List<ITriggerExternal> allExternalTriggers;
|
||||
|
||||
public static void initialize() {
|
||||
allExternalTriggers = Arrays.asList(
|
||||
lowResourceLiquid50 = new TriggerLowLiquid("lowLiquid.50", 0.5f),
|
||||
lowResourceLiquid25 = new TriggerLowLiquid("lowLiquid.25", 0.25f),
|
||||
lowSoil128 = new TriggerLowSoil(128),
|
||||
lowSoil64 = new TriggerLowSoil(64),
|
||||
lowSoil32 = new TriggerLowSoil(32),
|
||||
lowFertilizer50 = new TriggerLowFertilizer("lowFertilizer.50", 0.5f),
|
||||
lowFertilizer25 = new TriggerLowFertilizer("lowFertilizer.25", 0.25f),
|
||||
lowGermlings25 = new TriggerLowGermlings("lowGermlings.25", 0.25f),
|
||||
lowGermlings10 = new TriggerLowGermlings("lowGermlings.10", 0.1f)
|
||||
);
|
||||
// allExternalTriggers = Arrays.asList(
|
||||
// lowResourceLiquid50 = new TriggerLowLiquid("lowLiquid.50", 0.5f),
|
||||
// lowResourceLiquid25 = new TriggerLowLiquid("lowLiquid.25", 0.25f),
|
||||
// lowSoil128 = new TriggerLowSoil(128),
|
||||
// lowSoil64 = new TriggerLowSoil(64),
|
||||
// lowSoil32 = new TriggerLowSoil(32),
|
||||
// lowFertilizer50 = new TriggerLowFertilizer("lowFertilizer.50", 0.5f),
|
||||
// lowFertilizer25 = new TriggerLowFertilizer("lowFertilizer.25", 0.25f),
|
||||
// lowGermlings25 = new TriggerLowGermlings("lowGermlings.25", 0.25f),
|
||||
// lowGermlings10 = new TriggerLowGermlings("lowGermlings.10", 0.1f)
|
||||
// );
|
||||
}
|
||||
}
|
||||
@@ -10,39 +10,29 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowFertilizer {//} extends Trigger {
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
public class TriggerLowFertilizer extends Trigger {
|
||||
|
||||
private final float threshold;
|
||||
|
||||
public TriggerLowFertilizer(String tag, float threshold) {
|
||||
super(tag, "lowFertilizer");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IInventory fertilizerInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getFertilizerInventory();
|
||||
return InventoryUtil.containsPercent(fertilizerInventory, threshold);
|
||||
}
|
||||
// private final float threshold;
|
||||
//
|
||||
// public TriggerLowFertilizer(String tag, float threshold) {
|
||||
// super(tag, "lowFertilizer");
|
||||
// this.threshold = threshold;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// IInventory fertilizerInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getFertilizerInventory();
|
||||
// return InventoryUtil.containsPercent(fertilizerInventory, threshold);
|
||||
// }
|
||||
}
|
||||
@@ -10,42 +10,34 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowGermlings extends Trigger {
|
||||
|
||||
private final float threshold;
|
||||
|
||||
public TriggerLowGermlings(String tag, float threshold) {
|
||||
super(tag, "lowGermlings");
|
||||
// super(tag, "lowGermlings");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IInventory germlingsInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getGermlingsInventory();
|
||||
return InventoryUtil.containsPercent(germlingsInventory, threshold);
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// IInventory germlingsInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getGermlingsInventory();
|
||||
// return InventoryUtil.containsPercent(germlingsInventory, threshold);
|
||||
// }
|
||||
}
|
||||
@@ -10,49 +10,40 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowLiquid extends Trigger {
|
||||
|
||||
private final float threshold;
|
||||
|
||||
public TriggerLowLiquid(String tag, float threshold) {
|
||||
super(tag, "lowLiquid");
|
||||
// super(tag, "lowLiquid");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given
|
||||
* the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
ITankManager tankManager = tileHatch.getMultiblockLogic().getController().getTankManager();
|
||||
|
||||
IFluidTank tank = tankManager.getTank(0);
|
||||
if (tank.getCapacity() == 0) {
|
||||
return false;
|
||||
}
|
||||
return (float) tank.getFluidAmount() / tank.getCapacity() <= threshold;
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given
|
||||
// * the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// ITankManager tankManager = tileHatch.getMultiblockLogic().getController().getTankManager();
|
||||
//
|
||||
// IFluidTank tank = tankManager.getTank(0);
|
||||
// if (tank.getCapacity() == 0) {
|
||||
// return false;
|
||||
// }
|
||||
// return (float) tank.getFluidAmount() / tank.getCapacity() <= threshold;
|
||||
// }
|
||||
}
|
||||
@@ -10,65 +10,54 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.api.farming.IFarmInventory;
|
||||
import forestry.api.multiblock.IFarmController;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowSoil extends Trigger {
|
||||
|
||||
private final int threshold;
|
||||
|
||||
public TriggerLowSoil(int threshold) {
|
||||
super("lowSoil." + threshold, "lowSoil");
|
||||
// super("lowSoil." + threshold, "lowSoil");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxParameters() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given
|
||||
* the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
IStatementParameter parameter = null;
|
||||
if (parameters.length > 0) {
|
||||
parameter = parameters[0];
|
||||
}
|
||||
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IFarmController farmController = tileHatch.getMultiblockLogic().getController();
|
||||
IFarmInventory farmInventory = farmController.getFarmInventory();
|
||||
|
||||
if (parameter == null || parameter.getItemStack() == null) {
|
||||
IInventory resourcesInventory = farmInventory.getResourcesInventory();
|
||||
return InventoryUtil.containsPercent(resourcesInventory, threshold);
|
||||
} else {
|
||||
ItemStack filter = parameter.getItemStack().copy();
|
||||
filter.stackSize = threshold;
|
||||
return farmInventory.hasResources(new ItemStack[]{filter});
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int maxParameters() {
|
||||
// return 1;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given
|
||||
// * the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// IStatementParameter parameter = null;
|
||||
// if (parameters.length > 0) {
|
||||
// parameter = parameters[0];
|
||||
// }
|
||||
//
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// IFarmController farmController = tileHatch.getMultiblockLogic().getController();
|
||||
// IFarmInventory farmInventory = farmController.getFarmInventory();
|
||||
//
|
||||
// if (parameter == null || parameter.getItemStack() == null) {
|
||||
// IInventory resourcesInventory = farmInventory.getResourcesInventory();
|
||||
// return InventoryUtil.containsPercent(resourcesInventory, threshold);
|
||||
// } else {
|
||||
// ItemStack filter = parameter.getItemStack().copy();
|
||||
// filter.stackSize = threshold;
|
||||
// return farmInventory.hasResources(new ItemStack[]{filter});
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.food;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -25,12 +26,9 @@ public class BeverageEffectAntidote extends BeverageEffect {
|
||||
|
||||
@Override
|
||||
public void doEffect(World world, EntityPlayer player) {
|
||||
|
||||
if (world.rand.nextFloat() >= chance) {
|
||||
return;
|
||||
if (world.rand.nextFloat() < chance) {
|
||||
player.removePotionEffect(MobEffects.POISON);
|
||||
}
|
||||
|
||||
player.removePotionEffect(Potion.poison.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.food;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
@@ -23,7 +24,7 @@ public class BeverageEffectDrunk extends BeverageEffect {
|
||||
public BeverageEffectDrunk(int id, float chance) {
|
||||
super(id, "for.beverage.effect.alcoholic");
|
||||
this.chance = chance;
|
||||
this.drunkEffect = new PotionEffect(Potion.confusion.id, 25 * 20, 0);
|
||||
this.drunkEffect = new PotionEffect(MobEffects.NAUSEA, 25 * 20, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.food.items;
|
||||
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.items.ItemForestryFood;
|
||||
@@ -21,7 +23,8 @@ public class ItemAmbrosia extends ItemForestryFood {
|
||||
public ItemAmbrosia() {
|
||||
super(Constants.FOOD_AMBROSIA_HEAL, 0.6f);
|
||||
setAlwaysEdible();
|
||||
setPotionEffect(Potion.regeneration.id, 40, 0, 1.0F);
|
||||
PotionEffect potionEffect = new PotionEffect(MobEffects.REGENERATION, 40, 0);
|
||||
setPotionEffect(potionEffect, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.food.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -36,7 +37,7 @@ import forestry.core.items.ItemForestryFood;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
import forestry.food.BeverageEffect;
|
||||
|
||||
public class ItemBeverage extends ItemForestryFood {
|
||||
public class ItemBeverage extends ItemForestryFood implements IItemColor {
|
||||
public interface IBeverageInfo extends ItemOverlay.IOverlayInfo {
|
||||
int getHeal();
|
||||
|
||||
@@ -160,7 +161,7 @@ public class ItemBeverage extends ItemForestryFood {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemstack, int j) {
|
||||
public int getColorFromItemstack(ItemStack itemstack, int j) {
|
||||
if (j == 1 || beverages[itemstack.getItemDamage()].getSecondaryColor() == 0) {
|
||||
return beverages[itemstack.getItemDamage()].getPrimaryColor();
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
@@ -42,8 +43,13 @@ public class GreenhouseAccess implements IGreenhouseAccess {
|
||||
return;
|
||||
}
|
||||
Block block = Block.getBlockFromItem(glass.getItem());
|
||||
if (block == null || block.isOpaqueCube()) {
|
||||
Log.error("Fail to register greenhouse glass: " + block + ".");
|
||||
if (block == null) {
|
||||
Log.error("Fail to register greenhouse glass, it has no matching block: " + glass + ".");
|
||||
return;
|
||||
}
|
||||
IBlockState defaultBlockState = block.getDefaultState();
|
||||
if (block.isOpaqueCube(defaultBlockState)) {
|
||||
Log.error("Fail to register greenhouse glass, it is opaque: " + block + ".");
|
||||
return;
|
||||
}
|
||||
for (ItemStack greenhouseGlass : greenhouseGlasses.keySet()) {
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.greenhouse.blocks;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -75,7 +76,7 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,16 @@
|
||||
package forestry.greenhouse.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
@@ -27,50 +31,35 @@ public class ItemBlockGreenhouseDoor extends ItemBlockForestry<BlockGreenhouseDo
|
||||
public ItemBlockGreenhouseDoor(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copied from {@link ItemDoor#onItemUse(ItemStack, EntityPlayer, World, BlockPos, EnumHand, EnumFacing, float, float, float)}
|
||||
*/
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (side != EnumFacing.UP) {
|
||||
return false;
|
||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
if (facing != EnumFacing.UP) {
|
||||
return EnumActionResult.FAIL;
|
||||
} else {
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (!block.isReplaceable(worldIn, pos)) {
|
||||
pos = pos.offset(side);
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
if (!playerIn.canPlayerEdit(pos, side, stack)) {
|
||||
return false;
|
||||
} else if (!this.block.canPlaceBlockAt(worldIn, pos)) {
|
||||
return false;
|
||||
} else {
|
||||
placeDoor(worldIn, pos, EnumFacing.fromAngle(playerIn.rotationYaw), this.block);
|
||||
if (playerIn.canPlayerEdit(pos, facing, stack) && this.block.canPlaceBlockAt(worldIn, pos)) {
|
||||
EnumFacing enumfacing = EnumFacing.fromAngle((double) playerIn.rotationYaw);
|
||||
int i = enumfacing.getFrontOffsetX();
|
||||
int j = enumfacing.getFrontOffsetZ();
|
||||
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
|
||||
ItemDoor.placeDoor(worldIn, pos, enumfacing, this.block, flag);
|
||||
SoundType soundtype = this.block.getSoundType();
|
||||
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
--stack.stackSize;
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door) {
|
||||
BlockPos blockpos = pos.offset(facing.rotateY());
|
||||
BlockPos blockpos1 = pos.offset(facing.rotateYCCW());
|
||||
int i = (worldIn.getBlockState(blockpos1).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos1.up()).getBlock().isNormalCube() ? 1 : 0);
|
||||
int j = (worldIn.getBlockState(blockpos).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos.up()).getBlock().isNormalCube() ? 1 : 0);
|
||||
boolean flag = worldIn.getBlockState(blockpos1).getBlock() == door || worldIn.getBlockState(blockpos1.up()).getBlock() == door;
|
||||
boolean flag1 = worldIn.getBlockState(blockpos).getBlock() == door || worldIn.getBlockState(blockpos.up()).getBlock() == door;
|
||||
boolean flag2 = false;
|
||||
|
||||
if (flag && !flag1 || j > i) {
|
||||
flag2 = true;
|
||||
}
|
||||
|
||||
BlockPos blockpos2 = pos.up();
|
||||
IBlockState iblockstate = door.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, flag2 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT);
|
||||
worldIn.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
|
||||
worldIn.setBlockState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
|
||||
worldIn.notifyNeighborsOfStateChange(pos, door);
|
||||
worldIn.notifyNeighborsOfStateChange(blockpos2, door);
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user