mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Merge branch 'mc-1.12' of https://github.com/ForestryMC/ForestryMC into dev
This commit is contained in:
commit
98806129bc
20 files changed
+318
-91
No files matched your search
@@ -55,6 +55,7 @@ import forestry.modules.ModuleManager;
|
||||
import forestry.plugins.ForestryCompatPlugins;
|
||||
import forestry.plugins.PluginIC2;
|
||||
import forestry.plugins.PluginNatura;
|
||||
import forestry.plugins.PluginTechReborn;
|
||||
|
||||
/**
|
||||
* Forestry Minecraft Mod
|
||||
@@ -71,7 +72,8 @@ import forestry.plugins.PluginNatura;
|
||||
+ "after:jei@[4.7.8.91,);"
|
||||
+ "after:" + PluginIC2.MOD_ID + ";"
|
||||
+ "after:" + PluginNatura.MOD_ID + ";"
|
||||
+ "after:toughasnails;")
|
||||
+ "after:toughasnails;"
|
||||
+ "after:" + PluginTechReborn.MOD_ID + ";")
|
||||
public class Forestry {
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
|
||||
@@ -31,6 +31,8 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.PotionTypes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -157,9 +159,9 @@ public class ModuleApiculture extends BlankForestryModule {
|
||||
public static int ticksPerBeeWorkCycle = 550;
|
||||
|
||||
public static boolean hivesDamageOnPeaceful = false;
|
||||
|
||||
|
||||
public static boolean doSelfPollination = true;
|
||||
|
||||
|
||||
public static int maxFlowersSpawnedPerHive = 20;
|
||||
@Nullable
|
||||
public static VillagerRegistry.VillagerProfession villagerApiarist;
|
||||
@@ -282,7 +284,7 @@ public class ModuleApiculture extends BlankForestryModule {
|
||||
ticksPerBeeWorkCycle = config.getIntLocalized("beekeeping", "ticks.work", 550, 250, 850);
|
||||
|
||||
hivesDamageOnPeaceful = config.getBooleanLocalized("beekeeping", "hivedamage.peaceful", false);
|
||||
|
||||
|
||||
doSelfPollination = config.getBooleanLocalized("beekeeping", "self.pollination", false);
|
||||
|
||||
config.save();
|
||||
@@ -988,11 +990,52 @@ public class ModuleApiculture extends BlankForestryModule {
|
||||
HiveConfig.addBlacklistedDim(dim);
|
||||
}
|
||||
return true;
|
||||
} else if (message.key.equals("add-plantable-flower")) {
|
||||
return addPlantableFlower(message);
|
||||
} else if (message.key.equals("add-acceptable-flower")) {
|
||||
return addAcceptableFlower(message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean addPlantableFlower(IMCMessage message) {
|
||||
try {
|
||||
NBTTagCompound tagCompound = message.getNBTValue();
|
||||
IBlockState flowerState = NBTUtil.readBlockState(tagCompound);
|
||||
double weight = tagCompound.getDouble("weight");
|
||||
List<String> flowerTypes = new ArrayList<>();
|
||||
for (String key : tagCompound.getKeySet()) {
|
||||
if (key.contains("flowertype")) {
|
||||
flowerTypes.add(tagCompound.getString("flowertype"));
|
||||
}
|
||||
}
|
||||
FlowerManager.flowerRegistry.registerPlantableFlower(flowerState, weight, flowerTypes.toArray(new String[flowerTypes.size()]));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
IMCUtil.logInvalidIMCMessage(message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addAcceptableFlower(IMCMessage message) {
|
||||
try {
|
||||
NBTTagCompound tagCompound = message.getNBTValue();
|
||||
IBlockState flowerState = NBTUtil.readBlockState(tagCompound);
|
||||
List<String> flowerTypes = new ArrayList<>();
|
||||
for (String key : tagCompound.getKeySet()) {
|
||||
if (key.contains("flowertype")) {
|
||||
flowerTypes.add(tagCompound.getString("flowertype"));
|
||||
}
|
||||
}
|
||||
FlowerManager.flowerRegistry.registerAcceptableFlower(flowerState, flowerTypes.toArray(new String[flowerTypes.size()]));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
IMCUtil.logInvalidIMCMessage(message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void textureHook(TextureStitchEvent.Pre event) {
|
||||
|
||||
@@ -63,9 +63,9 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
|
||||
public static final Set<Item> lightingItems;
|
||||
public static final String colourTagName = "colour";
|
||||
|
||||
private static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
|
||||
public static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
|
||||
|
||||
private enum State implements IStringSerializable {
|
||||
enum State implements IStringSerializable {
|
||||
ON("on"), OFF("off");
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.apiculture.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -59,9 +58,7 @@ public class BlockStump extends BlockTorch implements IItemModelRegister {
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack heldItem = playerIn.getHeldItem(hand);
|
||||
if (BlockCandle.lightingItems.contains(heldItem.getItem())) {
|
||||
IBlockState blockState = worldIn.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
IBlockState activatedState = ModuleApiculture.getBlocks().candle.getStateFromMeta(block.getMetaFromState(blockState));
|
||||
IBlockState activatedState = ModuleApiculture.getBlocks().candle.getDefaultState().withProperty(BlockCandle.STATE, BlockCandle.State.ON);
|
||||
worldIn.setBlockState(pos, activatedState, Constants.FLAG_BLOCK_SYNC);
|
||||
TileCandle tc = new TileCandle();
|
||||
tc.setColour(16777215); // default to white
|
||||
|
||||
@@ -85,7 +85,7 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator> {
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
String str = Translator.translateToLocal("item.for.habitatLocator.name").toUpperCase();
|
||||
String str = Translator.translateToLocal("item.for.habitat_locator.name").toUpperCase();
|
||||
fontRenderer.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
// Set active according to valid biomes.
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Config {
|
||||
|
||||
//Humus
|
||||
public static int humusDegradeDelimiter = 3;
|
||||
|
||||
|
||||
//Greenhouse
|
||||
public static int climateSourceRange = 36;
|
||||
public static float climateSourceEnergyModifier = 1.5F;
|
||||
@@ -125,6 +125,7 @@ public class Config {
|
||||
|
||||
// Fluids
|
||||
public static boolean CapsuleFluidPickup = false;
|
||||
public static boolean nonConsumableCapsules = false;
|
||||
|
||||
// Gui tabs (Ledger)
|
||||
public static int guiTabSpeed = 8;
|
||||
@@ -158,37 +159,39 @@ public class Config {
|
||||
return enableExUtilEnderLily;
|
||||
}
|
||||
|
||||
public static boolean isExUtilRedOrchidEnabled() { return enableExUtilRedOrchid; }
|
||||
public static boolean isExUtilRedOrchidEnabled() {
|
||||
return enableExUtilRedOrchid;
|
||||
}
|
||||
|
||||
public static boolean isMagicalCropsSupportEnabled() {
|
||||
return enableMagicalCropsSupport;
|
||||
}
|
||||
|
||||
|
||||
public static void blacklistTreeDim(int dimID) {
|
||||
blacklistedTreeDims.add(dimID);
|
||||
}
|
||||
|
||||
|
||||
public static void whitelistTreeDim(int dimID) {
|
||||
whitelistedTreeDims.add(dimID);
|
||||
}
|
||||
|
||||
|
||||
public static void blacklistOreDim(int dimID) {
|
||||
blacklistedOreDims.add(dimID);
|
||||
}
|
||||
|
||||
|
||||
public static void whitelistOreDim(int dimID) {
|
||||
whitelistedOreDims.add(dimID);
|
||||
}
|
||||
|
||||
public static boolean isValidOreDim(int dimID) { //blacklist has priority
|
||||
if(blacklistedOreDims.isEmpty() || !blacklistedOreDims.contains(dimID)) {
|
||||
|
||||
public static boolean isValidOreDim(int dimID) { //blacklist has priority
|
||||
if (blacklistedOreDims.isEmpty() || !blacklistedOreDims.contains(dimID)) {
|
||||
return whitelistedOreDims.isEmpty() || whitelistedOreDims.contains(dimID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isValidTreeDim(int dimID) { //blacklist has priority
|
||||
if(blacklistedTreeDims.isEmpty() || !blacklistedTreeDims.contains(dimID)) {
|
||||
|
||||
public static boolean isValidTreeDim(int dimID) { //blacklist has priority
|
||||
if (blacklistedTreeDims.isEmpty() || !blacklistedTreeDims.contains(dimID)) {
|
||||
return whitelistedTreeDims.isEmpty() || whitelistedTreeDims.contains(dimID);
|
||||
}
|
||||
return false;
|
||||
@@ -262,24 +265,24 @@ public class Config {
|
||||
generateApatiteOre = configCommon.getBooleanLocalized("world.generate.ore", "apatite", generateApatiteOre);
|
||||
generateCopperOre = configCommon.getBooleanLocalized("world.generate.ore", "copper", generateCopperOre);
|
||||
generateTinOre = configCommon.getBooleanLocalized("world.generate.ore", "tin", generateTinOre);
|
||||
for(int dimId : configCommon.get("world.generate.ore", "dimBlacklist", new int[0]).getIntList()) {
|
||||
blacklistedOreDims.add(dimId);
|
||||
for (int dimId : configCommon.get("world.generate.ore", "dimBlacklist", new int[0]).getIntList()) {
|
||||
blacklistedOreDims.add(dimId);
|
||||
}
|
||||
for(int dimId : configCommon.get("world.generate.ore", "dimWhitelist", new int[0]).getIntList()) {
|
||||
for (int dimId : configCommon.get("world.generate.ore", "dimWhitelist", new int[0]).getIntList()) {
|
||||
whitelistedOreDims.add(dimId);
|
||||
}
|
||||
|
||||
|
||||
enableVillagers = configCommon.getBooleanLocalized("world.generate", "villagers", enableVillagers);
|
||||
|
||||
|
||||
generateTrees = configCommon.getBooleanLocalized("world.generate", "trees", generateTrees);
|
||||
for(int dimId : configCommon.get("world.generate.trees", "dimBlacklist", new int[0]).getIntList()){
|
||||
blacklistedTreeDims.add(dimId);
|
||||
for (int dimId : configCommon.get("world.generate.trees", "dimBlacklist", new int[0]).getIntList()) {
|
||||
blacklistedTreeDims.add(dimId);
|
||||
}
|
||||
for(int dimId : configCommon.get("world.generate.trees", "dimWhitelist", new int[0]).getIntList()){
|
||||
whitelistedTreeDims.add(dimId);
|
||||
}
|
||||
|
||||
|
||||
for (int dimId : configCommon.get("world.generate.trees", "dimWhitelist", new int[0]).getIntList()) {
|
||||
whitelistedTreeDims.add(dimId);
|
||||
}
|
||||
|
||||
|
||||
craftingBronzeEnabled = configCommon.getBooleanLocalized("crafting", "bronze", craftingBronzeEnabled);
|
||||
craftingStampsEnabled = configCommon.getBooleanLocalized("crafting.stamps", "enabled", true);
|
||||
|
||||
@@ -327,7 +330,8 @@ public class Config {
|
||||
ringFarms = configCommon.getBooleanLocalized("tweaks.cultivation", "ring", ringFarms);
|
||||
ringSize = configCommon.getIntLocalized("tweaks.cultivation", "ring_size", ringSize, 1, 8);
|
||||
|
||||
CapsuleFluidPickup = configCommon.getBooleanLocalized("tweaks", "capsule", CapsuleFluidPickup);
|
||||
CapsuleFluidPickup = configCommon.getBooleanLocalized("tweaks.capsule", "capsulePickup", CapsuleFluidPickup);
|
||||
nonConsumableCapsules = configCommon.getBooleanLocalized("tweaks.capsule", "capsuleReuseable", nonConsumableCapsules);
|
||||
|
||||
climateSourceRange = configCommon.getIntLocalized("tweaks.greenhouse", "range", climateSourceRange, 9, 270);
|
||||
climateSourceEnergyModifier = configCommon.getFloatLocalized("tweaks.greenhouse", "energy", climateSourceEnergyModifier, 0.0F, 15.0F);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStackSimple;
|
||||
|
||||
import forestry.core.config.Config;
|
||||
|
||||
public class FluidHandlerItemForestry extends FluidHandlerItemStackSimple.Consumable {
|
||||
private final EnumContainerType containerType;
|
||||
|
||||
@@ -42,5 +45,14 @@ public class FluidHandlerItemForestry extends FluidHandlerItemStackSimple.Consum
|
||||
super.setFluid(fluid);
|
||||
container.setItemDamage(1); // show the filled container model
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setContainerToEmpty() {
|
||||
if (Config.nonConsumableCapsules) { //default behaviour of FluidHandlerItemStack
|
||||
container.getTagCompound().removeTag(FLUID_NBT_KEY);
|
||||
} else {
|
||||
super.setContainerToEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ItemFluidContainerForestry extends ItemForestry {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
// empty
|
||||
subItems.add(new ItemStack(this));
|
||||
|
||||
|
||||
// filled
|
||||
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
|
||||
ItemStack itemStack = new ItemStack(this);
|
||||
@@ -194,9 +194,9 @@ public class ItemFluidContainerForestry extends ItemForestry {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, heldItem);
|
||||
}
|
||||
} else {
|
||||
if(Config.CapsuleFluidPickup) {
|
||||
if (Config.CapsuleFluidPickup) {
|
||||
RayTraceResult target = this.rayTrace(world, player, true);
|
||||
if (target.typeOfHit != RayTraceResult.Type.BLOCK) {
|
||||
if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK) {
|
||||
return ActionResult.newResult(EnumActionResult.PASS, heldItem);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -63,9 +65,9 @@ public class PacketFXSignal extends ForestryPacket implements IForestryPacketCli
|
||||
data.writeBlockPos(pos);
|
||||
data.writeByte(visualFX.ordinal());
|
||||
data.writeByte(soundFX.ordinal());
|
||||
Block block = blockState.getBlock();
|
||||
data.writeVarInt(Block.getIdFromBlock(block));
|
||||
data.writeVarInt(block.getMetaFromState(blockState));
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTUtil.writeBlockState(tag, blockState);
|
||||
data.writeCompoundTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,10 +82,9 @@ public class PacketFXSignal extends ForestryPacket implements IForestryPacketCli
|
||||
BlockPos pos = data.readBlockPos();
|
||||
VisualFXType visualFX = VisualFXType.values()[data.readByte()];
|
||||
SoundFXType soundFX = SoundFXType.values()[data.readByte()];
|
||||
Block block = Block.getBlockById(data.readVarInt());
|
||||
IBlockState blockState = block.getStateFromMeta(data.readVarInt());
|
||||
|
||||
World world = player.world;
|
||||
IBlockState blockState = NBTUtil.readBlockState(data.readCompoundTag());
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if (visualFX == VisualFXType.BLOCK_BREAK) {
|
||||
Minecraft.getMinecraft().effectRenderer.addBlockDestroyEffects(pos, blockState);
|
||||
|
||||
@@ -68,15 +68,16 @@ public class WorldGenerator implements IWorldGenerator {
|
||||
}
|
||||
|
||||
private void generateWorld(Random random, int chunkX, int chunkZ, World world) {
|
||||
if(!Config.isValidOreDim(world.provider.getDimension()))
|
||||
if (!Config.isValidOreDim(world.provider.getDimension())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (apatiteGenerator == null || copperGenerator == null || tinGenerator == null) {
|
||||
BlockResourceOre resourcesBlock = ModuleCore.getBlocks().resources;
|
||||
|
||||
IBlockState apatiteBlockState = resourcesBlock.getStateFromMeta(EnumResourceType.APATITE.getMeta());
|
||||
IBlockState copperBlockState = resourcesBlock.getStateFromMeta(EnumResourceType.COPPER.getMeta());
|
||||
IBlockState tinBlockState = resourcesBlock.getStateFromMeta(EnumResourceType.TIN.getMeta());
|
||||
IBlockState apatiteBlockState = resourcesBlock.getDefaultState().withProperty(BlockResourceOre.ORE_RESOURCES, EnumResourceType.APATITE);
|
||||
IBlockState copperBlockState = resourcesBlock.getDefaultState().withProperty(BlockResourceOre.ORE_RESOURCES, EnumResourceType.COPPER);
|
||||
IBlockState tinBlockState = resourcesBlock.getDefaultState().withProperty(BlockResourceOre.ORE_RESOURCES, EnumResourceType.TIN);
|
||||
apatiteGenerator = new WorldGenMinable(apatiteBlockState, 36);
|
||||
copperGenerator = new WorldGenMinable(copperBlockState, 6);
|
||||
tinGenerator = new WorldGenMinable(tinBlockState, 6);
|
||||
|
||||
@@ -28,8 +28,10 @@ import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmProperties;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.logic.crops.CropRubber;
|
||||
import forestry.plugins.PluginIC2;
|
||||
import forestry.plugins.PluginTechReborn;
|
||||
|
||||
public class FarmLogicRubber extends FarmLogic {
|
||||
|
||||
@@ -37,7 +39,8 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
|
||||
public FarmLogicRubber(IFarmProperties properties, boolean isManual) {
|
||||
super(properties, isManual);
|
||||
if (PluginIC2.rubberWood == null || PluginIC2.resin == null) {
|
||||
if ((PluginIC2.rubberWood == null || PluginIC2.resin == null) &&
|
||||
PluginTechReborn.rubberItemsSuccess()) {
|
||||
Log.warning("Failed to init a farm logic {} since IC2 rubber wood or resin were not found", getClass().getName());
|
||||
active = false;
|
||||
}
|
||||
@@ -45,7 +48,12 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return PluginIC2.resin;
|
||||
if (ModUtil.isModLoaded(PluginIC2.MOD_ID)) {
|
||||
return PluginIC2.resin;
|
||||
} else if (ModUtil.isModLoaded(PluginTechReborn.MOD_ID)) {
|
||||
return PluginTechReborn.sap;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,13 +127,14 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
BlockPos candidate = position.add(0, j, 0);
|
||||
|
||||
if(!world.isBlockLoaded(candidate)){
|
||||
if (!world.isBlockLoaded(candidate)) {
|
||||
return crops;
|
||||
}
|
||||
|
||||
IBlockState blockState = world.getBlockState(candidate);
|
||||
Block block = blockState.getBlock();
|
||||
if (!ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
if ((PluginIC2.rubberWood != null && !ItemStackUtil.equals(block, PluginIC2.rubberWood)) &&
|
||||
(PluginTechReborn.RUBBER_WOOD != null && !ItemStackUtil.equals(block, PluginTechReborn.RUBBER_WOOD))) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
@@ -29,6 +30,7 @@ import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import forestry.plugins.PluginIC2;
|
||||
import forestry.plugins.PluginTechReborn;
|
||||
|
||||
public class CropRubber extends CropDestroy {
|
||||
|
||||
@@ -46,6 +48,9 @@ public class CropRubber extends CropDestroy {
|
||||
String valueWetString = wetPropertyEntry.getValue().toString();
|
||||
String valueDryString = valueWetString.replace("wet", "dry");
|
||||
IProperty<?> property = wetPropertyEntry.getKey();
|
||||
if (property instanceof PropertyBool && property.getName().equals("hassap")) {
|
||||
return sappyState.withProperty(PropertyBool.create("hassap"), false);
|
||||
}
|
||||
|
||||
IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState();
|
||||
IBlockState dryState = getStateWithValue(baseState, property, valueDryString);
|
||||
@@ -60,13 +65,15 @@ public class CropRubber extends CropDestroy {
|
||||
|
||||
public static boolean hasRubberToHarvest(IBlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
if (PluginIC2.rubberWood != null && ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
ImmutableCollection<Comparable<?>> propertyValues = blockState.getProperties().values();
|
||||
for (Comparable<?> propertyValue : propertyValues) {
|
||||
if (propertyValue.toString().contains("wet")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (PluginTechReborn.RUBBER_WOOD != null && ItemStackUtil.equals(block, PluginTechReborn.RUBBER_WOOD)) {
|
||||
return blockState.getValue(PropertyBool.create("hassap"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -83,8 +90,12 @@ public class CropRubber extends CropDestroy {
|
||||
@Override
|
||||
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
|
||||
NonNullList<ItemStack> harvested = NonNullList.create();
|
||||
harvested.add(PluginIC2.resin.copy());
|
||||
|
||||
Block harvestBlock = world.getBlockState(pos).getBlock();
|
||||
if (PluginIC2.rubberWood != null && ItemStackUtil.equals(harvestBlock, PluginIC2.rubberWood)) {
|
||||
harvested.add(PluginIC2.resin.copy());
|
||||
} else if (PluginTechReborn.RUBBER_WOOD != null && ItemStackUtil.equals(harvestBlock, PluginTechReborn.RUBBER_WOOD)) {
|
||||
harvested.add(PluginTechReborn.sap.copy());
|
||||
}
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
|
||||
|
||||
@@ -28,8 +28,9 @@ public class FarmableRusticSapling implements IFarmable {
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
if (world.setBlockState(pos, germlingBlock.getStateFromMeta(germling.getItemDamage()))) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, germlingBlock.getStateFromMeta(germling.getItemDamage()));
|
||||
IBlockState blockState = germlingBlock.getStateFromMeta(germling.getItemDamage()); //TODO - stop using meta here
|
||||
if (world.setBlockState(pos, blockState)) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState);
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.tiles;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.farming.blocks.BlockFarm;
|
||||
import forestry.farming.blocks.EnumFarmBlockType;
|
||||
|
||||
public class TileFarmPlain extends TileFarm {
|
||||
@Override
|
||||
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
|
||||
@@ -21,7 +24,7 @@ public class TileFarmPlain extends TileFarm {
|
||||
// set band block meta
|
||||
int bandY = maxCoord.getY() - 1;
|
||||
if (getPos().getY() == bandY) {
|
||||
this.world.setBlockState(getPos(), getBlockType().getStateFromMeta(1), 2);
|
||||
this.world.setBlockState(getPos(), getBlockType().getDefaultState().withProperty(BlockFarm.META, EnumFarmBlockType.BAND), 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
if (rand.nextInt(24) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(entityItem.getItem());
|
||||
if (butterfly == null) {
|
||||
return false;
|
||||
@@ -163,25 +163,25 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
switch (this.type) {
|
||||
case CATERPILLAR:
|
||||
manager.registerItemModel(item, 0, "caterpillar");
|
||||
break;
|
||||
case BUTTERFLY:
|
||||
manager.registerItemModel(item, 0, "butterflyGE");
|
||||
break;
|
||||
case COCOON:
|
||||
manager.registerItemModel(item, new CocoonMeshDefinition());
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleButterflyCocoon) {
|
||||
for (int age = 0; age < 3; age++) {
|
||||
ModelBakery.registerItemVariants(this,
|
||||
((IAlleleButterflyCocoon) allele).getCocoonItemModel(age));
|
||||
case CATERPILLAR:
|
||||
manager.registerItemModel(item, 0, "caterpillar");
|
||||
break;
|
||||
case BUTTERFLY:
|
||||
manager.registerItemModel(item, 0, "butterflyGE");
|
||||
break;
|
||||
case COCOON:
|
||||
manager.registerItemModel(item, new CocoonMeshDefinition());
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleButterflyCocoon) {
|
||||
for (int age = 0; age < 3; age++) {
|
||||
ModelBakery.registerItemVariants(this,
|
||||
((IAlleleButterflyCocoon) allele).getCocoonItemModel(age));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
manager.registerItemModel(item, 0, "liquids/jar");
|
||||
break;
|
||||
default:
|
||||
manager.registerItemModel(item, 0, "liquids/jar");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,10 +191,10 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
NBTTagCompound tagCompound = itemstack.getTagCompound();
|
||||
IButterflyGenome genome;
|
||||
int age;
|
||||
if(tagCompound == null){
|
||||
if (tagCompound == null) {
|
||||
genome = ButterflyDefinition.CabbageWhite.getGenome();
|
||||
age = 0;
|
||||
}else {
|
||||
} else {
|
||||
if (!tagCompound.hasKey(NBT_AGE)) {
|
||||
tagCompound.setInteger(NBT_AGE, 0);
|
||||
}
|
||||
@@ -223,8 +223,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
if (type == EnumFlutterType.COCOON) {
|
||||
pos = ButterflyManager.butterflyRoot.plantCocoon(world, pos, flutter, player.getGameProfile(), getAge(stack), true);
|
||||
if (pos != BlockPos.ORIGIN) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos,
|
||||
world.getBlockState(pos));
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState);
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
@@ -257,30 +256,30 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setAge(ItemStack cocoon, int age){
|
||||
if(cocoon.isEmpty()){
|
||||
|
||||
public static void setAge(ItemStack cocoon, int age) {
|
||||
if (cocoon.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (ButterflyManager.butterflyRoot.getType(cocoon) != EnumFlutterType.COCOON) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tagCompound = cocoon.getTagCompound();
|
||||
if(tagCompound == null){
|
||||
if (tagCompound == null) {
|
||||
cocoon.setTagCompound(tagCompound = new NBTTagCompound());
|
||||
}
|
||||
tagCompound.setInteger(NBT_AGE, age);
|
||||
}
|
||||
|
||||
public static int getAge(ItemStack cocoon){
|
||||
if(cocoon.isEmpty()){
|
||||
|
||||
public static int getAge(ItemStack cocoon) {
|
||||
if (cocoon.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
if (ButterflyManager.butterflyRoot.getType(cocoon) != EnumFlutterType.COCOON) {
|
||||
return 0;
|
||||
}
|
||||
NBTTagCompound tagCompound = cocoon.getTagCompound();
|
||||
if(tagCompound == null){
|
||||
if (tagCompound == null) {
|
||||
return 0;
|
||||
}
|
||||
return tagCompound.getInteger(NBT_AGE);
|
||||
|
||||
@@ -40,4 +40,5 @@ public class ForestryModuleUids {
|
||||
public static final String RUSTIC = "rustic";
|
||||
public static final String ROOTS = "roots";
|
||||
public static final String BETTER_WITH_MODS = "betterwithmods";
|
||||
public static final String TECH_REBORN = "techreborn";
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package forestry.plugins;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ItemStackHolder;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.IFarmProperties;
|
||||
import forestry.api.modules.ForestryModule;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.BackpackManager;
|
||||
import forestry.apiculture.ModuleApiculture;
|
||||
import forestry.apiculture.items.EnumPropolis;
|
||||
import forestry.apiculture.items.ItemRegistryApiculture;
|
||||
import forestry.core.ModuleCore;
|
||||
import forestry.core.blocks.BlockBogEarth;
|
||||
import forestry.core.circuits.Circuits;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.EnumElectronTube;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import forestry.farming.circuits.CircuitFarmLogic;
|
||||
import forestry.farming.logic.FarmLogicRubber;
|
||||
import forestry.farming.logic.farmables.FarmableSapling;
|
||||
import forestry.modules.ForestryModuleUids;
|
||||
import forestry.modules.ModuleHelper;
|
||||
|
||||
import techreborn.api.ISubItemRetriever;
|
||||
import techreborn.api.TechRebornAPI;
|
||||
|
||||
@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.TECH_REBORN, name = "TechReborn", author = "temp1011", url = Constants.URL, unlocalizedDescription = "for.module.techreborn.description")
|
||||
public class PluginTechReborn extends CompatPlugin {
|
||||
|
||||
public static final String MOD_ID = "techreborn";
|
||||
|
||||
@ItemStackHolder("techreborn:rubber_log")
|
||||
@Nullable
|
||||
public static ItemStack RUBBER_WOOD = null;
|
||||
@ItemStackHolder("techreborn:rubber_sapling")
|
||||
@Nullable
|
||||
public static final ItemStack RUBBER_SAPLING = null;
|
||||
|
||||
public static ItemStack sap;
|
||||
public static ItemStack rubber;
|
||||
|
||||
public PluginTechReborn() {
|
||||
super("TechReborn", MOD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
IFarmProperties rubberFarm = FarmRegistry.getInstance().registerLogic("farmRubber", FarmLogicRubber::new);
|
||||
|
||||
Circuits.farmRubberManual = new CircuitFarmLogic("manualRubber", rubberFarm, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = MOD_ID)
|
||||
public void doInit() {
|
||||
ISubItemRetriever getItem = TechRebornAPI.subItemRetriever;
|
||||
sap = getItem.getPartByName("rubberSap");
|
||||
rubber = getItem.getPartByName("rubber");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = MOD_ID)
|
||||
public void registerCrates() {
|
||||
ItemStack scrap = TechRebornAPI.subItemRetriever.getPartByName("scrap");
|
||||
ItemStack uuMatter = getItemStack("uumatter");
|
||||
ModuleHelper.registerCrate(sap);
|
||||
ModuleHelper.registerCrate(scrap);
|
||||
ModuleHelper.registerCrate(uuMatter);
|
||||
ModuleHelper.registerCrate("ingotLead");
|
||||
ModuleHelper.registerCrate("ingotAluminum");
|
||||
ModuleHelper.registerCrate("ingotBrass");
|
||||
ModuleHelper.registerCrate("ingotNickel");
|
||||
|
||||
if (!ModUtil.isModLoaded(PluginIC2.MOD_ID)) {
|
||||
ModuleHelper.registerCrate("ingotSilver");
|
||||
ModuleHelper.registerCrate("itemRubber");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBackpackItems() {
|
||||
ModuleHelper.addItemToBackpack(BackpackManager.FORESTER_UID, sap);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = MOD_ID)
|
||||
public void registerRecipes() {
|
||||
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY,
|
||||
Fluids.GLASS.getFluid(500),
|
||||
ModuleCore.items.tubes.get(EnumElectronTube.RUBBER, 4),
|
||||
new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "itemRubber"});
|
||||
|
||||
if (ModuleHelper.isEnabled(ForestryModuleUids.APICULTURE)) {
|
||||
ItemRegistryApiculture beeItems = ModuleApiculture.getItems();
|
||||
if (!ModUtil.isModLoaded(PluginIC2.MOD_ID)) {
|
||||
RecipeManagers.centrifugeManager.addRecipe(20, beeItems.propolis.get(EnumPropolis.NORMAL, 1), ImmutableMap.of(sap, 1.0f));
|
||||
} else {
|
||||
Log.info("Using ic2 Propolis recipe rather than Tech Reborn");
|
||||
}
|
||||
}
|
||||
|
||||
int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can");
|
||||
if (bogEarthOutputCan > 0) {
|
||||
ItemStack waterCell = TechRebornAPI.subItemRetriever.getCellByName("water");
|
||||
ItemStack bogEarthCan = ModuleCore.getBlocks().bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, bogEarthOutputCan);
|
||||
RecipeUtil.addRecipe("techreborn_bog_earth_can", bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waterCell, 'Y', "sand");
|
||||
}
|
||||
|
||||
if (ModuleHelper.isEnabled(ForestryModuleUids.FARMING)) {
|
||||
ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual");
|
||||
ChipsetManager.solderManager.addRecipe(layoutManual, ModuleCore.items.tubes.get(EnumElectronTube.RUBBER, 1), Circuits.farmRubberManual);
|
||||
ForestryAPI.farmRegistry.registerFarmables("rubberTreeFarm", new FarmableSapling(RUBBER_SAPLING, new ItemStack[0]));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean rubberItemsSuccess() {
|
||||
return ItemStackUtil.getItemFromRegistry("techreborn:rubber_wood") != null
|
||||
&& !new ItemStack(ItemStackUtil.getItemFromRegistry("techreborn:part"), 1, 31).isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user