mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
1 parent
fd25e0822d
commit
0ff0aa802c
7 files changed
+175
-9
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")
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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