mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e3c23e4eb | ||
|
|
d8ffc5c4b8 | ||
|
|
737f64eeab | ||
|
|
0db27d83b0 | ||
|
|
f57de19b06 | ||
|
|
1fed58fae5 | ||
|
|
1d8d61daf1 | ||
|
|
65bd93749c | ||
|
|
ac48b4b5c6 | ||
|
|
3be3ecfc8a | ||
|
|
10aae6b6bc | ||
|
|
d84560926c | ||
|
|
ab3de49198 | ||
|
|
b2b743398c | ||
|
|
52f233e84a | ||
|
|
2f2ec91670 | ||
|
|
2e2fa8e6df | ||
|
|
3de6e0c5b7 | ||
|
|
0f4ba8d8fa | ||
|
|
9570d26c83 | ||
|
|
01dc4f2bfe | ||
|
|
80de4d6490 | ||
|
|
253e9f18ed | ||
|
|
bbda5c8ba9 | ||
|
|
c289590740 | ||
|
|
714858be99 | ||
|
|
5bb60cad8a | ||
|
|
b8cf4ef1cf | ||
|
|
d35075d681 | ||
|
|
79c56311c2 | ||
|
|
77cea8a645 | ||
|
|
ed00ca3158 | ||
|
|
418f00abf2 | ||
|
|
0fa8fdad39 | ||
|
|
0a110eb761 | ||
|
|
9feb5cb114 | ||
|
|
7aa44fb1fa | ||
|
|
84fa956ce4 | ||
|
|
0c14a85c31 | ||
|
|
a20fbbe60f | ||
|
|
27d932ee34 | ||
|
|
52b1784f25 | ||
|
|
154f4f2712 | ||
|
|
806ca2cf7b | ||
|
|
9f171977bb | ||
|
|
2031f7fe02 | ||
|
|
4259a55e7a | ||
|
|
065344ba5e | ||
|
|
d0c9a77528 | ||
|
|
604429f267 | ||
|
|
f5a9dcccb8 | ||
|
|
b056cce707 | ||
|
|
1497aada57 | ||
|
|
fb8ddf54b7 | ||
|
|
9a05322d45 | ||
|
|
8c2008b06c | ||
|
|
e3cc08a624 | ||
|
|
36cd4663d9 | ||
|
|
a014ef6d14 | ||
|
|
34fa218c38 | ||
|
|
f422b577fe | ||
|
|
e379465227 | ||
|
|
eb63e75200 | ||
|
|
b5faab51c3 |
No files matched your search
+1
-7
@@ -108,13 +108,7 @@ allprojects {
|
||||
}
|
||||
|
||||
jar {
|
||||
// Copy redstone api into the jar, should shade this as a maven dep...
|
||||
from (sourceSets.api.allSource) {
|
||||
include 'cofh/**/*.txt'
|
||||
}
|
||||
from (sourceSets.api.output.classesDir) {
|
||||
include 'cofh/**/*.*'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
mcversion=1.10.2
|
||||
forgeversion=12.18.1.2050
|
||||
forgeversion=12.18.1.2094
|
||||
mcp_mappings=snapshot_20160525
|
||||
|
||||
tesla_version=1.10.2-1.2.1.41
|
||||
jei_version=3.8.0.240
|
||||
ic2_version=2.6.15-ex110
|
||||
tesla_version=1.10.2-1.2.1.49
|
||||
jei_version=3.12.2.290
|
||||
ic2_version=2.6.76-ex110
|
||||
|
||||
version_major=5
|
||||
version_minor=2
|
||||
version_patch=8
|
||||
version_patch=14
|
||||
+1
-1
Submodule lang updated: 0d52088d32...a31d99f6f6.
@@ -12,6 +12,20 @@ package forestry;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.EventHandlerCore;
|
||||
import forestry.core.climate.ClimateEventHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.GameMode;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.multiblock.MultiblockEventHandler;
|
||||
import forestry.core.network.PacketHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.worldgen.WorldGenerator;
|
||||
import forestry.plugins.PluginManager;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -26,20 +40,6 @@ import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.EventHandlerCore;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.GameMode;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.multiblock.MultiblockEventHandler;
|
||||
import forestry.core.network.PacketHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.worldgen.WorldGenerator;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
/**
|
||||
* Forestry Minecraft Mod
|
||||
*
|
||||
@@ -51,8 +51,8 @@ import forestry.plugins.PluginManager;
|
||||
version = Constants.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
acceptedMinecraftVersions = "[1.10]",
|
||||
dependencies = "required-after:Forge@[12.18.0.1989,);"
|
||||
+ "after:JEI@[3.8.0,);"
|
||||
dependencies = "required-after:Forge@[12.18.1.2080,);"
|
||||
+ "after:JEI@[3.11.2.278,);"
|
||||
+ "after:" + PluginIC2.modId + ";")
|
||||
public class Forestry {
|
||||
|
||||
@@ -78,6 +78,7 @@ public class Forestry {
|
||||
EventHandlerCore eventHandlerCore = new EventHandlerCore();
|
||||
MinecraftForge.EVENT_BUS.register(eventHandlerCore);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ClimateEventHandler());
|
||||
|
||||
configFolder = new File(event.getModConfigurationDirectory(), Constants.MOD_ID);
|
||||
Config.load();
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
|
||||
public class ApicultureCapabilities {
|
||||
/**
|
||||
* Capability for {@link IArmorApiarist}.
|
||||
* The {@link Capability#getDefaultInstance()} will always protect the wearer with no side effects.
|
||||
*/
|
||||
@CapabilityInject(IArmorApiarist.class)
|
||||
public static Capability<IArmorApiarist> ARMOR_APIARIST;
|
||||
}
|
||||
@@ -5,21 +5,24 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* When implemented by armor piece items, allows them to act as apiarist's armor.
|
||||
* When implemented as a capability by armor items, protects the wearer from negative bee effects.
|
||||
* @see ApicultureCapabilities#ARMOR_APIARIST
|
||||
*/
|
||||
public interface IArmorApiarist {
|
||||
/**
|
||||
* Called when the apiarist's armor acts as protection against an attack.
|
||||
*
|
||||
* @param entity Entity being attacked
|
||||
* @param armor Armor item
|
||||
* @param cause Optional cause of attack, such as a bee effect identifier
|
||||
* @param entity Entity being attacked
|
||||
* @param armor Armor item
|
||||
* @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 Whether or not the armor should protect the player from that attack
|
||||
*/
|
||||
boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect);
|
||||
boolean protectEntity(EntityLivingBase entity, ItemStack armor, @Nullable String cause, boolean doProtect);
|
||||
}
|
||||
@@ -5,37 +5,29 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.IClimateProvider;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.climate.IClimateProvider;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.core.ILocatable;
|
||||
import forestry.api.genetics.IHousing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public interface IBeeHousing extends IHousing, IErrorLogicSource, IClimateProvider {
|
||||
public interface IBeeHousing extends IHousing, IErrorLogicSource, IClimateProvider, ILocatable {
|
||||
|
||||
/**
|
||||
* Used by BeeManager.beeRoot.createBeeHousingModifier(IBeeHousing housing)
|
||||
* Used by {@link IBeeRoot#createBeeHousingModifier(IBeeHousing)}
|
||||
* to combine bee modifiers from several sources that can change over time.
|
||||
* @return IBeeModifiers from the housing, frames, etc.
|
||||
*/
|
||||
Iterable<IBeeModifier> getBeeModifiers();
|
||||
|
||||
/**
|
||||
* Used by BeeManager.beeRoot.createBeeHousingListener(IBeeHousing housing)
|
||||
* Used by {@link IBeeRoot#createBeeHousingListener(IBeeHousing)}
|
||||
* to combine bee listeners from several sources that can change over time.
|
||||
* @return IBeeListeners from the housing, multiblock parts, etc.
|
||||
*/
|
||||
Iterable<IBeeListener> getBeeListeners();
|
||||
|
||||
@Nonnull
|
||||
IBeeHousingInventory getBeeInventory();
|
||||
|
||||
IBeekeepingLogic getBeekeepingLogic();
|
||||
@@ -44,14 +36,11 @@ public interface IBeeHousing extends IHousing, IErrorLogicSource, IClimateProvid
|
||||
|
||||
boolean canBlockSeeTheSky();
|
||||
|
||||
/** Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12 */
|
||||
World getWorldObj();
|
||||
|
||||
GameProfile getOwner();
|
||||
|
||||
/**
|
||||
* @since Forestry 4.2
|
||||
* @return exact coordinates where bee FX should spawn from
|
||||
* @return exact coordinates where bee particle FX should spawn from
|
||||
*/
|
||||
Vec3d getBeeFXCoordinates();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
|
||||
public class ArboricultureCapabilities {
|
||||
/**
|
||||
* Capability for {@link IArmorNaturalist}.
|
||||
* The {@link Capability#getDefaultInstance()} will always show pollination with no side effects.
|
||||
*/
|
||||
@CapabilityInject(IArmorNaturalist.class)
|
||||
public static Capability<IArmorNaturalist> ARMOR_NATURALIST;
|
||||
}
|
||||
@@ -92,11 +92,38 @@ public enum EnumForestryWoodType implements IWoodType {
|
||||
return VALUES[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCarbonization() {
|
||||
return carbonization;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCombustability() {
|
||||
return combustability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlankTexture() {
|
||||
return "forestry:blocks/wood/planks." + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDoorLowerTexture() {
|
||||
return "forestry:blocks/doors/" + getName() + "_lower";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDoorUpperTexture() {
|
||||
return "forestry:blocks/doors/" + getName() + "_upper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBarkTexture() {
|
||||
return "forestry:blocks/wood/bark." + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeartTexture() {
|
||||
return "forestry:blocks/wood/heart." + getName();
|
||||
}
|
||||
}
|
||||
@@ -71,4 +71,44 @@ public enum EnumVanillaWoodType implements IWoodType {
|
||||
public int getCombustability() {
|
||||
return combustability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlankTexture() {
|
||||
if(this == DARK_OAK){
|
||||
return "blocks/planks_big_oak";
|
||||
}
|
||||
return "blocks/planks_" + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDoorLowerTexture() {
|
||||
if(this == OAK){
|
||||
return "blocks/door_wood_lower";
|
||||
}
|
||||
return "blocks/door_wood_lower";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDoorUpperTexture() {
|
||||
if(this == OAK){
|
||||
return "blocks/door_wood_upper";
|
||||
}
|
||||
return "blocks/door_" + getName() + "_upper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBarkTexture() {
|
||||
if(this == DARK_OAK){
|
||||
return "blocks/log_big_oak";
|
||||
}
|
||||
return "blocks/log_" + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeartTexture() {
|
||||
if(this == DARK_OAK){
|
||||
return "blocks/log_big_oak_top";
|
||||
}
|
||||
return "blocks/log_" + getName() + "_top";
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -22,5 +24,7 @@ public interface IWoodAccess {
|
||||
ItemStack getStack(IWoodType woodType, WoodBlockKind kind, boolean fireproof);
|
||||
|
||||
IBlockState getBlock(IWoodType woodType, WoodBlockKind kind, boolean fireproof);
|
||||
|
||||
List<IWoodType> getRegisteredWoodTypes();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IWoodItemMeshDefinition extends ItemMeshDefinition {
|
||||
|
||||
ResourceLocation getDefaultModelLocation(ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IWoodStateMapper extends IStateMapper {
|
||||
|
||||
ModelResourceLocation getModelLocation(IBlockState state);
|
||||
|
||||
ModelResourceLocation getDefaultModelResourceLocation(IBlockState state);
|
||||
|
||||
}
|
||||
@@ -14,4 +14,14 @@ public interface IWoodType extends IStringSerializable {
|
||||
int getCarbonization();
|
||||
|
||||
int getCombustability();
|
||||
|
||||
String getPlankTexture();
|
||||
|
||||
String getDoorLowerTexture();
|
||||
|
||||
String getDoorUpperTexture();
|
||||
|
||||
String getBarkTexture();
|
||||
|
||||
String getHeartTexture();
|
||||
}
|
||||
@@ -1,12 +1,68 @@
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelProcessingHelper;
|
||||
|
||||
public enum WoodBlockKind {
|
||||
LOG, PLANKS, SLAB, FENCE, FENCE_GATE, STAIRS, DOOR;
|
||||
LOG, PLANKS, SLAB, FENCE, FENCE_GATE, STAIRS, DOOR(false);
|
||||
|
||||
public final boolean retextureItem;
|
||||
|
||||
private WoodBlockKind() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
private WoodBlockKind(boolean retextureItem) {
|
||||
this.retextureItem = retextureItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public IModel retextureModel(IModel model, IWoodType type, ImmutableMap<String, String> customTextures){
|
||||
Map<String, String> textures = new HashMap<>();
|
||||
switch (this) {
|
||||
case SLAB:
|
||||
case STAIRS:
|
||||
String textureLocation = type.getPlankTexture();
|
||||
textures.put("particle", textureLocation);
|
||||
textures.put("side", textureLocation);
|
||||
textures.put("top", textureLocation);
|
||||
textures.put("bottom", textureLocation);
|
||||
textures.put("all", textureLocation);
|
||||
break;
|
||||
case PLANKS:
|
||||
textures.put("particle", type.getPlankTexture());
|
||||
textures.put("all", type.getPlankTexture());
|
||||
break;
|
||||
case FENCE_GATE:
|
||||
case FENCE:
|
||||
textures.put("particle", type.getPlankTexture());
|
||||
textures.put("side", type.getPlankTexture());
|
||||
textures.put("texture", type.getPlankTexture());
|
||||
break;
|
||||
case DOOR:
|
||||
textures.put("particle", type.getDoorLowerTexture());
|
||||
textures.put("bottom", type.getDoorLowerTexture());
|
||||
textures.put("top", type.getDoorUpperTexture());
|
||||
break;
|
||||
case LOG:
|
||||
textures.put("particle", type.getBarkTexture());
|
||||
textures.put("side", type.getBarkTexture());
|
||||
textures.put("all", type.getBarkTexture());
|
||||
textures.put("end", type.getHeartTexture());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
textures.putAll(customTextures);
|
||||
return ModelProcessingHelper.retexture(model, new ImmutableMap.Builder<String, String>().putAll(textures).build());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package forestry.api.climate;
|
||||
|
||||
public enum EnumClimatiserModes {
|
||||
|
||||
POSITIVE, NEGATIVE, NONE
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package forestry.api.climate;
|
||||
|
||||
public enum EnumClimatiserTypes {
|
||||
|
||||
TEMPERATURE, HUMIDITY, NONE
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
public interface IClimateControl {
|
||||
|
||||
float getControlTemperature();
|
||||
|
||||
float getControlHumidity();
|
||||
|
||||
void setControlTemperature(float temperature);
|
||||
|
||||
void setControlHumidity(float humidity);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
public interface IClimateControlProvider extends ILocatable {
|
||||
|
||||
IClimateControl getClimateControl();
|
||||
|
||||
}
|
||||
+3
-8
@@ -1,14 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
package forestry.api.climate;
|
||||
|
||||
public interface IClimateControlled {
|
||||
/**
|
||||
+23
-3
@@ -3,7 +3,13 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
package forestry.api.climate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -13,7 +19,21 @@ public interface IClimateManager {
|
||||
float getTemperature(World world, BlockPos pos);
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
|
||||
IClimateProvider getDefaultClimate(World world, BlockPos pos);
|
||||
|
||||
|
||||
void addRegion(IClimateRegion region);
|
||||
|
||||
void removeRegion(IClimateRegion region);
|
||||
|
||||
void addSource(IClimateSourceProvider source);
|
||||
|
||||
void removeSource(IClimateSourceProvider source);
|
||||
|
||||
@Nullable
|
||||
IClimateRegion getRegionForPos(World world, BlockPos pos);
|
||||
|
||||
@Nonnull
|
||||
Map<Integer, List<IClimateRegion>> getRegions();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IClimatePosition extends INbtReadable, INbtWritable {
|
||||
|
||||
@Nonnull
|
||||
IClimateRegion getClimateRegion();
|
||||
|
||||
@Nonnull
|
||||
BlockPos getPos();
|
||||
|
||||
void setTemperature(float temperature);
|
||||
|
||||
void addTemperature(float temperature);
|
||||
|
||||
float getTemperature();
|
||||
|
||||
void setHumidity(float humidity);
|
||||
|
||||
void addHumidity(float humidity);
|
||||
|
||||
float getHumidity();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public interface IClimateProvider {
|
||||
Biome getBiome();
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
EnumHumidity getHumidity();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateRegion extends INbtReadable, INbtWritable {
|
||||
|
||||
@Nonnull
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Update the climate in a region.
|
||||
*/
|
||||
void updateClimate(int ticks);
|
||||
|
||||
int getTicksPerUpdate();
|
||||
|
||||
@Nonnull
|
||||
Map<BlockPos, IClimatePosition> getPositions();
|
||||
|
||||
void addSource(IClimateSource source);
|
||||
|
||||
void removeSource(IClimateSource source);
|
||||
|
||||
Collection<IClimateSource> getSources();
|
||||
|
||||
Collection<BlockPos> getOtherPositions();
|
||||
|
||||
float getTemperature();
|
||||
|
||||
float getHumidity();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
/**
|
||||
* A climate source is used to change the climate in a region.
|
||||
*/
|
||||
public interface IClimateSource {
|
||||
|
||||
/**
|
||||
* @param tickCount The current tick count.
|
||||
* @param region The climate region, in that the source stands.
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateRegion region);
|
||||
|
||||
/**
|
||||
* @return The ticks that are required for one change.
|
||||
*/
|
||||
int getTicksForChange(IClimateRegion region);
|
||||
|
||||
IClimateSourceProvider getProvider();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
import forestry.api.core.ILocatable;
|
||||
|
||||
public interface IClimateSourceProvider extends ILocatable {
|
||||
|
||||
IClimateSource getClimateSource();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.climate;
|
||||
|
||||
public interface IClimatiserDefinition {
|
||||
|
||||
float getChange();
|
||||
|
||||
double getRange();
|
||||
|
||||
EnumClimatiserModes getMode();
|
||||
|
||||
EnumClimatiserTypes getType();
|
||||
|
||||
}
|
||||
+3
-6
@@ -3,10 +3,7 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
@API(apiVersion = "2.1.0", owner = "Forestry", provides = "ForestryAPI|climate")
|
||||
package forestry.api.climate;
|
||||
|
||||
public enum EnumCamouflageType {
|
||||
DEFAULT, GLASS, DOOR;
|
||||
|
||||
public static final EnumCamouflageType[] VALUES = values();
|
||||
}
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
public class CamouflageManager {
|
||||
|
||||
public static ICamouflageAccess camouflageAccess;
|
||||
|
||||
public static final String DEFAULT = "default";
|
||||
|
||||
public static final String GLASS = "glass";
|
||||
|
||||
public static final String DOOR = "door";
|
||||
|
||||
}
|
||||
@@ -60,15 +60,15 @@ public enum EnumTemperature {
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumTemperature getFromBiome(Biome Biome) {
|
||||
if (BiomeHelper.isBiomeHellish(Biome)) {
|
||||
public static EnumTemperature getFromBiome(Biome biome) {
|
||||
if (BiomeHelper.isBiomeHellish(biome)) {
|
||||
return HELLISH;
|
||||
}
|
||||
return getFromValue(Biome.getTemperature());
|
||||
return getFromValue(biome.getTemperature());
|
||||
}
|
||||
|
||||
public static EnumTemperature getFromBiome(Biome Biome, World world, BlockPos pos) {
|
||||
if (BiomeHelper.isBiomeHellish(Biome)) {
|
||||
public static EnumTemperature getFromBiome(Biome biome, World world, BlockPos pos) {
|
||||
if (BiomeHelper.isBiomeHellish(biome)) {
|
||||
return HELLISH;
|
||||
}
|
||||
float temperature = ForestryAPI.climateManager.getTemperature(world, pos);
|
||||
|
||||
@@ -7,6 +7,7 @@ package forestry.api.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.climate.IClimateManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -5,20 +5,23 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import forestry.api.arboriculture.ArboricultureCapabilities;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Naturalist armor allows players to see pollinated tree leaves.
|
||||
*
|
||||
* @see ArboricultureCapabilities#ARMOR_NATURALIST
|
||||
*/
|
||||
public interface IArmorNaturalist {
|
||||
|
||||
/**
|
||||
* Called when the naturalist's armor acts as spectacles for seeing pollinated tree leaves/flowers.
|
||||
* Called to see if this naturalist's armor allows for seeing pollinated tree leaves/flowers.
|
||||
*
|
||||
* @param player
|
||||
* Player doing the viewing
|
||||
* @param armor
|
||||
* Armor item
|
||||
* @param doSee
|
||||
* Whether or not to actually do the side effects of viewing
|
||||
* @param player Player doing the viewing
|
||||
* @param armor Armor item
|
||||
* @param doSee Whether or not to actually do the side effects of viewing
|
||||
* @return true if the armor actually allows the player to see pollination.
|
||||
*/
|
||||
boolean canSeePollination(EntityPlayer player, ItemStack armor, boolean doSee);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ICamouflageAccess {
|
||||
|
||||
/**
|
||||
* Register a item camouflage handler for a type.
|
||||
*
|
||||
* @param type The camouflage type for of handler.
|
||||
* @param itemHandler The handler that is to register.
|
||||
*/
|
||||
void registerCamouflageItemHandler(@Nonnull ICamouflageItemHandler itemHandler);
|
||||
|
||||
/**
|
||||
* @return A list of all item camouflage handler's that are registered for that camouflage type.
|
||||
*/
|
||||
List<ICamouflageItemHandler> getCamouflageItemHandler(@Nonnull String type);
|
||||
|
||||
void addItemToBlackList(@Nonnull String type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
boolean isItemBlackListed(@Nonnull String type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
ICamouflageItemHandler getHandlerFromItem(ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -6,28 +6,26 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ICamouflageHandler{
|
||||
public interface ICamouflageHandler extends ILocatable {
|
||||
|
||||
/**
|
||||
* @return The item of the block that is the camouflage of this handler for the EnumCamouflageType.
|
||||
* @return The item of the block that is the camouflage of this handler for the type.
|
||||
*/
|
||||
ItemStack getCamouflageBlock(EnumCamouflageType type);
|
||||
|
||||
/**
|
||||
* @return The default camouflage block item for the EnumCamouflageType.
|
||||
*/
|
||||
ItemStack getDefaultCamouflageBlock(EnumCamouflageType type);
|
||||
ItemStack getCamouflageBlock(String type);
|
||||
|
||||
/**
|
||||
* Set the camouflage block item for the EnumCamouflageType.
|
||||
* @return The default camouflage block item for the type.
|
||||
*/
|
||||
void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock);
|
||||
|
||||
ItemStack getDefaultCamouflageBlock(String type);
|
||||
|
||||
/**
|
||||
* @return The coordinates of the handler as a BlockPos.
|
||||
* @return True if the handler can handle this type of camouflage.
|
||||
*/
|
||||
BlockPos getCoordinates();
|
||||
|
||||
boolean canHandleType(String type);
|
||||
|
||||
/**
|
||||
* Set the camouflage block item for the type.
|
||||
*/
|
||||
void setCamouflageBlock(String type, ItemStack camouflageBlock);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface ICamouflageItemHandler {
|
||||
|
||||
boolean canHandle(ItemStack stack);
|
||||
|
||||
String getType();
|
||||
|
||||
float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile);
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ICamouflagedTile {
|
||||
|
||||
EnumCamouflageType getCamouflageType();
|
||||
String getCamouflageType();
|
||||
|
||||
BlockPos getCoordinates();
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public interface IClimateProvider {
|
||||
Biome getBiome();
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
EnumHumidity getHumidity();
|
||||
}
|
||||
+21
-21
@@ -1,21 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* 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.tiles;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ILocatable {
|
||||
BlockPos getCoordinates();
|
||||
|
||||
/** Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12 */
|
||||
World getWorldObj();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ILocatable {
|
||||
BlockPos getCoordinates();
|
||||
|
||||
/** Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12 */
|
||||
World getWorldObj();
|
||||
}
|
||||
@@ -8,8 +8,6 @@ package forestry.api.core;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* Called after Forestry has registered all his species alleles of a individual.
|
||||
*/
|
||||
public class AlleleSpeciesRegisterEvent extends Event {
|
||||
|
||||
private final ISpeciesRoot root;
|
||||
|
||||
public AlleleSpeciesRegisterEvent(ISpeciesRoot root) {
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public ISpeciesRoot getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,23 +3,22 @@ package forestry.api.genetics;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.gui.GuiAlyzer;
|
||||
|
||||
public interface IAlyzerPlugin {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void drawAnalyticsPage1(GuiAlyzer gui, ItemStack itemStack);
|
||||
void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void drawAnalyticsPage2(GuiAlyzer gui, ItemStack itemStack);
|
||||
void drawAnalyticsPage2(GuiScreen gui, ItemStack itemStack);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void drawAnalyticsPage3(GuiAlyzer gui, ItemStack itemStack);
|
||||
void drawAnalyticsPage3(GuiScreen gui, ItemStack itemStack);
|
||||
|
||||
Map<String, ItemStack> getIconStacks();
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
/** Set custom mutation requirements */
|
||||
public interface IMutationBuilder {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import forestry.api.core.IClimateProvider;
|
||||
import forestry.api.climate.IClimateProvider;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
public class DefaultGreenhouseListener implements IGreenhouseListener {
|
||||
|
||||
@Override
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork) {
|
||||
public boolean canWork(IGreenhouseController greenhouse, boolean canWork) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
@@ -15,17 +10,17 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
public class GreenhouseEvents extends Event {
|
||||
|
||||
@Nullable
|
||||
public final IGreenhouseState state;
|
||||
public final IGreenhouseController controller;
|
||||
|
||||
public GreenhouseEvents(@Nullable IGreenhouseState state) {
|
||||
this.state = state;
|
||||
public GreenhouseEvents(@Nullable IGreenhouseController state) {
|
||||
this.controller = state;
|
||||
}
|
||||
|
||||
public static class CamouflageChangeEvent extends GreenhouseEvents{
|
||||
@@ -35,10 +30,10 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public ICamouflageHandler camouflageHandler;
|
||||
@Nonnull
|
||||
public final EnumCamouflageType camouflageType;
|
||||
public final String camouflageType;
|
||||
|
||||
public CamouflageChangeEvent(IGreenhouseState state, @Nullable ICamouflagedTile camouflagedBlock, @Nonnull ICamouflageHandler camouflageHandler, @Nonnull EnumCamouflageType camouflageType) {
|
||||
super(state);
|
||||
public CamouflageChangeEvent(IGreenhouseController controller, @Nullable ICamouflagedTile camouflagedBlock, @Nonnull ICamouflageHandler camouflageHandler, @Nonnull String camouflageType) {
|
||||
super(controller);
|
||||
|
||||
this.camouflagedBlock = camouflagedBlock;
|
||||
this.camouflageHandler = camouflageHandler;
|
||||
@@ -51,8 +46,8 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public IInternalBlock internalBlock;
|
||||
|
||||
public InternalBlockEvent(IGreenhouseState state, @Nonnull IInternalBlock internalBlock) {
|
||||
super(state);
|
||||
public InternalBlockEvent(IGreenhouseController controller, @Nonnull IInternalBlock internalBlock) {
|
||||
super(controller);
|
||||
|
||||
this.internalBlock = internalBlock;
|
||||
}
|
||||
@@ -60,8 +55,8 @@ public class GreenhouseEvents extends Event {
|
||||
|
||||
public static class CreateInternalBlockEvent extends InternalBlockEvent{
|
||||
|
||||
public CreateInternalBlockEvent(IGreenhouseState state, IInternalBlock internalBlock) {
|
||||
super(state, internalBlock);
|
||||
public CreateInternalBlockEvent(IGreenhouseController controller, IInternalBlock internalBlock) {
|
||||
super(controller, internalBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +65,8 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public final IInternalBlockFace face;
|
||||
|
||||
public CheckInternalBlockFaceEvent(IGreenhouseState state, IInternalBlock internalBlock, @Nonnull IInternalBlockFace face) {
|
||||
super(state, internalBlock);
|
||||
public CheckInternalBlockFaceEvent(IGreenhouseController controller, IInternalBlock internalBlock, @Nonnull IInternalBlockFace face) {
|
||||
super(controller, internalBlock);
|
||||
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
@@ -5,15 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GreenhouseManager {
|
||||
|
||||
public static IGreenhouseAccess greenhouseAccess;
|
||||
|
||||
public static IGreenhouseHelper greenhouseHelper;
|
||||
|
||||
public static List<Class<? extends IGreenhouseLogic>> greenhouseLogics = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IGreenhouseAccess {
|
||||
|
||||
void registerGreenhouseGlass(@Nonnull ItemStack glass, float lightTransmittance);
|
||||
|
||||
boolean isGreenhouseGlass(@Nonnull ItemStack glass);
|
||||
|
||||
float getGreenhouseGlassLightTransmittance(@Nonnull ItemStack glass);
|
||||
|
||||
void addToCamouflageBlockBlackList(@Nonnull EnumCamouflageType type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
boolean isOnCamouflageBlockBlackList(@Nonnull EnumCamouflageType type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
}
|
||||
@@ -5,14 +5,21 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGreenhouseHelper {
|
||||
|
||||
/**
|
||||
* @return A {@link IGreenhouseState} of a greenhouse, when the pos is a greenhouse
|
||||
* @return A {@link IGreenhouseController} of a greenhouse, when the pos is a greenhouse
|
||||
*/
|
||||
IGreenhouseState getGreenhouseState(World world, BlockPos pos);
|
||||
IGreenhouseController getGreenhouseController(World world, BlockPos pos);
|
||||
|
||||
void addGreenhouseLogic(Class<? extends IGreenhouseLogic> logic);
|
||||
|
||||
List<Class<? extends IGreenhouseLogic>> getGreenhouseLogics();
|
||||
|
||||
}
|
||||
@@ -10,12 +10,12 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
public interface IGreenhouseListener {
|
||||
|
||||
/**
|
||||
* Called before the greenhouse work.
|
||||
* Called before the greenhouse update the climate system.
|
||||
*
|
||||
* @param greenhouse The greenhouse multiblock.
|
||||
* @param greenhouse The greenhouse of the listener.
|
||||
* @param canWork The actual {@link Boolean} value.
|
||||
* @return True if the greenhouse can work.
|
||||
* @return True if the greenhouse can update the climate.
|
||||
*/
|
||||
<G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork);
|
||||
boolean canWork(IGreenhouseController greenhouse, boolean canWork);
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
|
||||
public interface IGreenhouseState {
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
EnumHumidity getHumidity();
|
||||
|
||||
float getExactTemperature();
|
||||
|
||||
float getExactHumidity();
|
||||
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
|
||||
Collection<IMultiblockComponent> getGreenhouseComponents();
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion = "5.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|greenhouse")
|
||||
@API(apiVersion = "5.2.0", owner = "ForestryAPI|core", provides = "ForestryAPI|greenhouse")
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -5,7 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.lepidopterology;
|
||||
|
||||
import forestry.api.core.IClimateProvider;
|
||||
import forestry.api.climate.IClimateProvider;
|
||||
import forestry.api.genetics.IHousing;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.climate.IClimateControlled;
|
||||
|
||||
/**
|
||||
* Needs to be implemented by TileEntities that want to be part of an alveary.
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateControlProvider;
|
||||
import forestry.api.climate.IClimateSourceProvider;
|
||||
import forestry.api.climate.IClimatiserDefinition;
|
||||
import forestry.api.greenhouse.IGreenhouseListener;
|
||||
import forestry.api.lepidopterology.IButterflyCocoon;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -19,11 +21,17 @@ public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> exte
|
||||
IGreenhouseListener getGreenhouseListener();
|
||||
}
|
||||
|
||||
interface ClimateControl extends IGreenhouseComponent, IClimateControlProvider {
|
||||
|
||||
@Override
|
||||
IClimateControl getClimateControl();
|
||||
}
|
||||
|
||||
interface Door extends IGreenhouseComponent {
|
||||
}
|
||||
|
||||
interface Climatiser extends IGreenhouseComponent {
|
||||
<G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tickCount, G greenhouse);
|
||||
interface Climatiser extends IGreenhouseComponent, IClimateSourceProvider {
|
||||
IClimatiserDefinition getDefinition();
|
||||
}
|
||||
|
||||
interface ButterflyHatch extends IGreenhouseComponent {
|
||||
|
||||
@@ -7,13 +7,18 @@ package forestry.api.multiblock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateControlProvider;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlled {
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlProvider {
|
||||
|
||||
/**
|
||||
* Handle change events.
|
||||
@@ -24,5 +29,12 @@ public interface IGreenhouseController extends IMultiblockController, IGreenhous
|
||||
* @return The logics of the greenhouse.
|
||||
*/
|
||||
List<IGreenhouseLogic> getLogics();
|
||||
|
||||
@Nullable
|
||||
IClimateRegion getRegion();
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
IClimateControl getClimateControl();
|
||||
|
||||
}
|
||||
@@ -15,4 +15,6 @@ public interface IMultiblockLogicFactory {
|
||||
IMultiblockLogicFarm createFarmLogic();
|
||||
|
||||
IMultiblockLogicGreenhouse createGreenhouseLogic();
|
||||
|
||||
IMultiblockLogicCharcoalPile createCharcoalPileLogic();
|
||||
}
|
||||
@@ -8,7 +8,6 @@ package forestry.api.recipes;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface ICarpenterRecipe extends IForestryRecipe {
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.recipes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
/**
|
||||
@@ -30,4 +33,7 @@ public interface IDescriptiveRecipe extends IRecipe {
|
||||
*/
|
||||
Object[] getIngredients();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
ItemStack getRecipeOutput();
|
||||
}
|
||||
@@ -10,13 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.apiculture.ApicultureCapabilities;
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.apiculture.IArmorApiaristHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.apiculture.IArmorApiaristHelper;
|
||||
|
||||
public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
|
||||
@Override
|
||||
@@ -25,12 +25,16 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
if (!(item instanceof IArmorApiarist)) {
|
||||
final Item item = stack.getItem();
|
||||
final IArmorApiarist armorApiarist;
|
||||
if (item instanceof IArmorApiarist) { // legacy
|
||||
armorApiarist = (IArmorApiarist) item;
|
||||
} else if (stack.hasCapability(ApicultureCapabilities.ARMOR_APIARIST, null)) {
|
||||
armorApiarist = stack.getCapability(ApicultureCapabilities.ARMOR_APIARIST, null);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
IArmorApiarist armorApiarist = (IArmorApiarist) item;
|
||||
return armorApiarist.protectEntity(entity, stack, cause, doProtect);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import forestry.Forestry;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.apiculture.hives.HiveManager;
|
||||
import forestry.api.apiculture.hives.IHiveRegistry.HiveType;
|
||||
@@ -36,6 +37,7 @@ import forestry.api.storage.StorageManager;
|
||||
import forestry.apiculture.blocks.BlockAlvearyType;
|
||||
import forestry.apiculture.blocks.BlockCandle;
|
||||
import forestry.apiculture.blocks.BlockRegistryApiculture;
|
||||
import forestry.apiculture.capabilities.ArmorApiarist;
|
||||
import forestry.apiculture.commands.CommandBee;
|
||||
import forestry.apiculture.entities.EntityMinecartApiary;
|
||||
import forestry.apiculture.entities.EntityMinecartBeehouse;
|
||||
@@ -72,6 +74,7 @@ import forestry.apiculture.worldgen.HiveRegistry;
|
||||
import forestry.core.ISaveEventHandler;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.PluginFluids;
|
||||
import forestry.core.capabilities.NullStorage;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.LocalizedConfiguration;
|
||||
@@ -106,6 +109,7 @@ import net.minecraft.world.storage.loot.LootTableList;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -161,6 +165,9 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
BeeManager.beeRoot.registerBeekeepingMode(BeekeepingMode.hard);
|
||||
BeeManager.beeRoot.registerBeekeepingMode(BeekeepingMode.hardcore);
|
||||
BeeManager.beeRoot.registerBeekeepingMode(BeekeepingMode.insane);
|
||||
|
||||
// Capabilities
|
||||
CapabilityManager.INSTANCE.register(IArmorApiarist.class, new NullStorage<>(), () -> ArmorApiarist.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -556,7 +563,7 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{items.honeydew.getItemStack()}, honeyDropFluid);
|
||||
|
||||
ItemStack phosphor = PluginCore.items.phosphor.getItemStack(2);
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND)}, new FluidStack(FluidRegistry.WATER, 2000));
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND)}, new FluidStack(FluidRegistry.LAVA, 2000));
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND, 1, 1)}, new FluidStack(FluidRegistry.LAVA, 2000));
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.DIRT)}, new FluidStack(FluidRegistry.LAVA, 1600));
|
||||
|
||||
|
||||
@@ -286,6 +286,11 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
|
||||
boolean isLit = isLit(stack);
|
||||
tileCandle.setColour(colour);
|
||||
tileCandle.setLit(isLit);
|
||||
if (tileCandle.isLit()) {
|
||||
world.theProfiler.startSection("checkLight");
|
||||
world.checkLight(pos);
|
||||
world.theProfiler.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -322,19 +327,11 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
|
||||
}
|
||||
|
||||
public ItemStack getUnlitCandle(int amount) {
|
||||
ItemStack itemStack = new ItemStack(this, amount, 0);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger(BlockCandle.colourTagName, 0xffffff);
|
||||
itemStack.setTagCompound(tag);
|
||||
return itemStack;
|
||||
return new ItemStack(this, amount, 0);
|
||||
}
|
||||
|
||||
public ItemStack getLitCandle(int amount) {
|
||||
ItemStack itemStack = new ItemStack(this, amount, 1);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger(BlockCandle.colourTagName, 0xffffff);
|
||||
itemStack.setTagCompound(tag);
|
||||
return itemStack;
|
||||
return new ItemStack(this, amount, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,10 +60,11 @@ public class BlockStump extends BlockTorch implements IItemModelRegister {
|
||||
if (heldItem != null && BlockCandle.lightingItems.contains(heldItem.getItem())) {
|
||||
IBlockState blockState = worldIn.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
IBlockState activatedState = PluginApiculture.blocks.candle.getStateFromMeta(block.getMetaFromState(blockState) | 0x08);
|
||||
IBlockState activatedState = PluginApiculture.blocks.candle.getStateFromMeta(block.getMetaFromState(blockState));
|
||||
worldIn.setBlockState(pos, activatedState, Constants.FLAG_BLOCK_SYNC);
|
||||
TileCandle tc = new TileCandle();
|
||||
tc.setColour(0); // default to white
|
||||
tc.setColour(16777215); // default to white
|
||||
tc.setLit(true);
|
||||
worldIn.setTileEntity(pos, tc);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package forestry.apiculture.capabilities;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ArmorApiarist implements IArmorApiarist {
|
||||
public static final ArmorApiarist INSTANCE = new ArmorApiarist();
|
||||
|
||||
protected ArmorApiarist() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean protectEntity(EntityLivingBase entity, ItemStack armor, @Nullable String cause, boolean doProtect) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ package forestry.apiculture.compat;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import forestry.apiculture.items.ItemRegistryApiculture;
|
||||
import forestry.core.genetics.Genome;
|
||||
import forestry.core.utils.JeiUtil;
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.ISubtypeRegistry;
|
||||
@@ -19,29 +19,31 @@ import net.minecraft.item.ItemStack;
|
||||
public class ApicultureJeiPlugin extends BlankModPlugin {
|
||||
@Override
|
||||
public void register(@Nonnull IModRegistry registry) {
|
||||
List<ItemStack> frames = Arrays.asList(
|
||||
new ItemStack(PluginApiculture.items.frameImpregnated),
|
||||
new ItemStack(PluginApiculture.items.frameProven),
|
||||
new ItemStack(PluginApiculture.items.frameUntreated)
|
||||
ItemRegistryApiculture items = PluginApiculture.items;
|
||||
|
||||
JeiUtil.addDescription(registry, "frames",
|
||||
items.frameImpregnated,
|
||||
items.frameProven,
|
||||
items.frameUntreated
|
||||
);
|
||||
registry.addDescription(frames, "for.jei.description.frames");
|
||||
|
||||
List<ItemStack> apiaristSuit = Arrays.asList(
|
||||
new ItemStack(PluginApiculture.items.apiaristBoots),
|
||||
new ItemStack(PluginApiculture.items.apiaristChest),
|
||||
new ItemStack(PluginApiculture.items.apiaristHat),
|
||||
new ItemStack(PluginApiculture.items.apiaristLegs)
|
||||
JeiUtil.addDescription(registry, "apiarist.suit",
|
||||
items.apiaristBoots,
|
||||
items.apiaristChest,
|
||||
items.apiaristHat,
|
||||
items.apiaristLegs
|
||||
);
|
||||
registry.addDescription(apiaristSuit, "for.jei.description.apiarist.suit");
|
||||
|
||||
registry.addDescription(new ItemStack(PluginApiculture.items.habitatLocator), "for.jei.description.habitat.locator");
|
||||
|
||||
registry.addDescription(new ItemStack(PluginApiculture.items.scoop), "for.jei.description.scoop");
|
||||
JeiUtil.addDescription(registry,
|
||||
items.habitatLocator,
|
||||
items.scoop,
|
||||
items.imprinter
|
||||
);
|
||||
|
||||
ISubtypeRegistry subtypeRegistry = registry.getJeiHelpers().getSubtypeRegistry();
|
||||
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beeDroneGE, BeeSubtypeInterpreter.INSTANCE);
|
||||
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beePrincessGE, BeeSubtypeInterpreter.INSTANCE);
|
||||
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beeQueenGE, BeeSubtypeInterpreter.INSTANCE);
|
||||
subtypeRegistry.registerNbtInterpreter(items.beeDroneGE, BeeSubtypeInterpreter.INSTANCE);
|
||||
subtypeRegistry.registerNbtInterpreter(items.beePrincessGE, BeeSubtypeInterpreter.INSTANCE);
|
||||
subtypeRegistry.registerNbtInterpreter(items.beeQueenGE, BeeSubtypeInterpreter.INSTANCE);
|
||||
}
|
||||
|
||||
private static class BeeSubtypeInterpreter implements ISubtypeRegistry.ISubtypeInterpreter {
|
||||
|
||||
@@ -248,7 +248,6 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public Set<IErrorState> getCanWork(IBeeHousing housing) {
|
||||
World world = housing.getWorldObj();
|
||||
Biome biome = housing.getBiome();
|
||||
BlockPos housingCoords = housing.getCoordinates();
|
||||
|
||||
Set<IErrorState> errorStates = new HashSet<>();
|
||||
@@ -282,7 +281,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
|
||||
// / Check for the sky, except if in hell
|
||||
if (biome != null && !BiomeHelper.isBiomeHellish(biome)) {
|
||||
if (!world.provider.getHasNoSky()) {
|
||||
if (!housing.canBlockSeeTheSky() && !canWorkUnderground(beeModifier)) {
|
||||
errorStates.add(EnumErrorCode.NO_SKY);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -47,208 +48,217 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void drawAnalyticsPage1(GuiAlyzer gui, ItemStack itemStack) {
|
||||
IBee bee = BeeManager.beeRoot.getMember(itemStack);
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
|
||||
|
||||
TextLayoutHelper textLayout = gui.getTextLayout();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
{
|
||||
String customPrimaryBeeKey = "for.bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", "");
|
||||
String customSecondaryBeeKey = "for.bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getSecondary().getUnlocalizedName().replace("bees.species.", "");
|
||||
|
||||
gui.drawSpeciesRow(Translator.translateToLocal("for.gui.species"), bee, EnumBeeChromosome.SPECIES, GuiAlyzer.checkCustomName(customPrimaryBeeKey), GuiAlyzer.checkCustomName(customSecondaryBeeKey));
|
||||
public void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack) {
|
||||
if(gui instanceof GuiAlyzer){
|
||||
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
|
||||
IBee bee = BeeManager.beeRoot.getMember(itemStack);
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
|
||||
|
||||
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
{
|
||||
String customPrimaryBeeKey = "for.bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", "");
|
||||
String customSecondaryBeeKey = "for.bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getSecondary().getUnlocalizedName().replace("bees.species.", "");
|
||||
|
||||
guiAlyzer.drawSpeciesRow(Translator.translateToLocal("for.gui.species"), bee, EnumBeeChromosome.SPECIES, GuiAlyzer.checkCustomName(customPrimaryBeeKey), GuiAlyzer.checkCustomName(customSecondaryBeeKey));
|
||||
textLayout.newLine();
|
||||
}
|
||||
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN);
|
||||
textLayout.newLine();
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.speed"), bee, EnumBeeChromosome.SPEED);
|
||||
textLayout.newLine();
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.pollination"), bee, EnumBeeChromosome.FLOWERING);
|
||||
textLayout.newLine();
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER);
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.fertility"), GuiAlyzer.COLUMN_0);
|
||||
IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY);
|
||||
IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY);
|
||||
guiAlyzer.drawFertilityInfo(primaryFertility.getValue(), GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(primaryFertility.isDominant()), 0);
|
||||
guiAlyzer.drawFertilityInfo(secondaryFertility.getValue(), GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(secondaryFertility.isDominant()), 0);
|
||||
textLayout.newLine();
|
||||
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.area"), bee, EnumBeeChromosome.TERRITORY);
|
||||
textLayout.newLine();
|
||||
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.effect"), bee, EnumBeeChromosome.EFFECT);
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN);
|
||||
textLayout.newLine();
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.speed"), bee, EnumBeeChromosome.SPEED);
|
||||
textLayout.newLine();
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.pollination"), bee, EnumBeeChromosome.FLOWERING);
|
||||
textLayout.newLine();
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER);
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.fertility"), GuiAlyzer.COLUMN_0);
|
||||
IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY);
|
||||
IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY);
|
||||
gui.drawFertilityInfo(primaryFertility.getValue(), GuiAlyzer.COLUMN_1, gui.getColorCoding(primaryFertility.isDominant()), 0);
|
||||
gui.drawFertilityInfo(secondaryFertility.getValue(), GuiAlyzer.COLUMN_2, gui.getColorCoding(secondaryFertility.isDominant()), 0);
|
||||
textLayout.newLine();
|
||||
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.area"), bee, EnumBeeChromosome.TERRITORY);
|
||||
textLayout.newLine();
|
||||
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.effect"), bee, EnumBeeChromosome.EFFECT);
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void drawAnalyticsPage2(GuiAlyzer gui, ItemStack itemStack) {
|
||||
IBee bee = BeeManager.beeRoot.getMember(itemStack);
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
|
||||
|
||||
TextLayoutHelper textLayout = gui.getTextLayout();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
gui.drawRow(Translator.translateToLocal("for.gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()),
|
||||
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTolerance tempToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
|
||||
gui.drawToleranceInfo(tempToleranceActive, GuiAlyzer.COLUMN_1);
|
||||
gui.drawToleranceInfo(tempToleranceInactive, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine(16);
|
||||
|
||||
gui.drawRow(Translator.translateToLocal("for.gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()),
|
||||
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTolerance humidToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
|
||||
gui.drawToleranceInfo(humidToleranceActive, GuiAlyzer.COLUMN_1);
|
||||
gui.drawToleranceInfo(humidToleranceInactive, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine(16);
|
||||
|
||||
String yes = Translator.translateToLocal("for.yes");
|
||||
String no = Translator.translateToLocal("for.no");
|
||||
|
||||
String diurnal0, diurnal1, nocturnal0, nocturnal1;
|
||||
if (bee.getGenome().getNeverSleeps()) {
|
||||
nocturnal0 = diurnal0 = yes;
|
||||
} else {
|
||||
nocturnal0 = bee.getGenome().getPrimary().isNocturnal() ? yes : no;
|
||||
diurnal0 = !bee.getGenome().getPrimary().isNocturnal() ? yes : no;
|
||||
}
|
||||
if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NEVER_SLEEPS)).getValue()) {
|
||||
nocturnal1 = diurnal1 = yes;
|
||||
} else {
|
||||
nocturnal1 = bee.getGenome().getSecondary().isNocturnal() ? yes : no;
|
||||
diurnal1 = !bee.getGenome().getSecondary().isNocturnal() ? yes : no;
|
||||
}
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.diurnal"), GuiAlyzer.COLUMN_0);
|
||||
textLayout.drawLine(diurnal0, GuiAlyzer.COLUMN_1, gui.getColorCoding(false));
|
||||
textLayout.drawLine(diurnal1, GuiAlyzer.COLUMN_2, gui.getColorCoding(false));
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.nocturnal"), GuiAlyzer.COLUMN_0);
|
||||
textLayout.drawLine(nocturnal0, GuiAlyzer.COLUMN_1, gui.getColorCoding(false));
|
||||
textLayout.drawLine(nocturnal1, GuiAlyzer.COLUMN_2, gui.getColorCoding(false));
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
String primary = StringUtil.readableBoolean(bee.getGenome().getToleratesRain(), yes, no);
|
||||
String secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERATES_RAIN)).getValue(), yes, no);
|
||||
|
||||
gui.drawRow(Translator.translateToLocal("for.gui.flyer"), primary, secondary, bee, EnumBeeChromosome.TOLERATES_RAIN);
|
||||
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
primary = StringUtil.readableBoolean(bee.getGenome().getCaveDwelling(), yes, no);
|
||||
secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no);
|
||||
|
||||
gui.drawRow(Translator.translateToLocal("for.gui.cave"), primary, secondary, bee, EnumBeeChromosome.CAVE_DWELLING);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
String displayText;
|
||||
if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) {
|
||||
String displayTextKey = "for.bees.stock.pristine";
|
||||
if (!bee.isNatural()) {
|
||||
displayTextKey = "for.bees.stock.ignoble";
|
||||
public void drawAnalyticsPage2(GuiScreen gui, ItemStack itemStack) {
|
||||
if(gui instanceof GuiAlyzer){
|
||||
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
|
||||
IBee bee = BeeManager.beeRoot.getMember(itemStack);
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
displayText = Translator.translateToLocal(displayTextKey);
|
||||
textLayout.drawCenteredLine(displayText, 8, 208, gui.getFontColor().get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
if (bee.getGeneration() >= 0) {
|
||||
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
|
||||
|
||||
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()),
|
||||
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTolerance tempToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
|
||||
guiAlyzer.drawToleranceInfo(tempToleranceActive, GuiAlyzer.COLUMN_1);
|
||||
guiAlyzer.drawToleranceInfo(tempToleranceInactive, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine(16);
|
||||
|
||||
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()),
|
||||
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTolerance humidToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
textLayout.drawLine(" " + Translator.translateToLocal("for.gui.tolerance"), GuiAlyzer.COLUMN_0);
|
||||
guiAlyzer.drawToleranceInfo(humidToleranceActive, GuiAlyzer.COLUMN_1);
|
||||
guiAlyzer.drawToleranceInfo(humidToleranceInactive, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine(16);
|
||||
|
||||
String yes = Translator.translateToLocal("for.yes");
|
||||
String no = Translator.translateToLocal("for.no");
|
||||
|
||||
String diurnal0, diurnal1, nocturnal0, nocturnal1;
|
||||
if (bee.getGenome().getNeverSleeps()) {
|
||||
nocturnal0 = diurnal0 = yes;
|
||||
} else {
|
||||
nocturnal0 = bee.getGenome().getPrimary().isNocturnal() ? yes : no;
|
||||
diurnal0 = !bee.getGenome().getPrimary().isNocturnal() ? yes : no;
|
||||
}
|
||||
if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NEVER_SLEEPS)).getValue()) {
|
||||
nocturnal1 = diurnal1 = yes;
|
||||
} else {
|
||||
nocturnal1 = bee.getGenome().getSecondary().isNocturnal() ? yes : no;
|
||||
diurnal1 = !bee.getGenome().getSecondary().isNocturnal() ? yes : no;
|
||||
}
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.diurnal"), GuiAlyzer.COLUMN_0);
|
||||
textLayout.drawLine(diurnal0, GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(false));
|
||||
textLayout.drawLine(diurnal1, GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(false));
|
||||
textLayout.newLineCompressed();
|
||||
displayText = Translator.translateToLocalFormatted("for.gui.beealyzer.generations", bee.getGeneration());
|
||||
textLayout.drawCenteredLine(displayText, 8, 208, gui.getFontColor().get("gui.beealyzer.binomial"));
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.nocturnal"), GuiAlyzer.COLUMN_0);
|
||||
textLayout.drawLine(nocturnal0, GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(false));
|
||||
textLayout.drawLine(nocturnal1, GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(false));
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
String primary = StringUtil.readableBoolean(bee.getGenome().getToleratesRain(), yes, no);
|
||||
String secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERATES_RAIN)).getValue(), yes, no);
|
||||
|
||||
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.flyer"), primary, secondary, bee, EnumBeeChromosome.TOLERATES_RAIN);
|
||||
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
primary = StringUtil.readableBoolean(bee.getGenome().getCaveDwelling(), yes, no);
|
||||
secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no);
|
||||
|
||||
guiAlyzer.drawRow(Translator.translateToLocal("for.gui.cave"), primary, secondary, bee, EnumBeeChromosome.CAVE_DWELLING);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
String displayText;
|
||||
if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) {
|
||||
String displayTextKey = "for.bees.stock.pristine";
|
||||
if (!bee.isNatural()) {
|
||||
displayTextKey = "for.bees.stock.ignoble";
|
||||
}
|
||||
displayText = Translator.translateToLocal(displayTextKey);
|
||||
textLayout.drawCenteredLine(displayText, 8, 208, guiAlyzer.getFontColor().get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
if (bee.getGeneration() >= 0) {
|
||||
textLayout.newLineCompressed();
|
||||
displayText = Translator.translateToLocalFormatted("for.gui.beealyzer.generations", bee.getGeneration());
|
||||
textLayout.drawCenteredLine(displayText, 8, 208, guiAlyzer.getFontColor().get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void drawAnalyticsPage3(GuiAlyzer gui, ItemStack itemStack) {
|
||||
IBee bee = BeeManager.beeRoot.getMember(itemStack);
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TextLayoutHelper textLayout = gui.getTextLayout();
|
||||
WidgetManager widgetManager = gui.getWidgetManager();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.produce") + ":", GuiAlyzer.COLUMN_0);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
int x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : bee.getProduceList()) {
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
public void drawAnalyticsPage3(GuiScreen gui, ItemStack itemStack) {
|
||||
if(gui instanceof GuiAlyzer){
|
||||
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
|
||||
IBee bee = BeeManager.beeRoot.getMember(itemStack);
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.specialty") + ":", GuiAlyzer.COLUMN_0);
|
||||
textLayout.newLine();
|
||||
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : bee.getSpecialtyList()) {
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
|
||||
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
|
||||
WidgetManager widgetManager = guiAlyzer.getWidgetManager();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.produce") + ":", GuiAlyzer.COLUMN_0);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
int x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : bee.getProduceList()) {
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.specialty") + ":", GuiAlyzer.COLUMN_0);
|
||||
textLayout.newLine();
|
||||
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : bee.getSpecialtyList()) {
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
@@ -32,6 +32,7 @@ import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeMutationBuilder;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleSpeciesRegisterEvent;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import forestry.apiculture.genetics.alleles.AlleleEffect;
|
||||
@@ -1019,6 +1020,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
for (BeeDefinition bee : values()) {
|
||||
bee.registerMutations();
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new AlleleSpeciesRegisterEvent(BeeManager.beeRoot));
|
||||
}
|
||||
|
||||
public static void preInit() {
|
||||
|
||||
@@ -10,26 +10,29 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.items;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
import forestry.api.apiculture.ApicultureCapabilities;
|
||||
import forestry.api.arboriculture.ArboricultureCapabilities;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import forestry.core.config.Constants;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArmorNaturalist, IItemModelRegister {
|
||||
public class ItemArmorApiarist extends ItemArmor implements IItemModelRegister {
|
||||
|
||||
public ItemArmorApiarist(EntityEquipmentSlot equipmentSlotIn) {
|
||||
super(ArmorMaterial.LEATHER, 0, equipmentSlotIn);
|
||||
@@ -57,14 +60,28 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect) {
|
||||
return true;
|
||||
}
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
|
||||
return new ICapabilityProvider() {
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == ArboricultureCapabilities.ARMOR_NATURALIST) {
|
||||
return armorType == EntityEquipmentSlot.HEAD;
|
||||
}
|
||||
return capability == ApicultureCapabilities.ARMOR_APIARIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeePollination(EntityPlayer player, ItemStack armor, boolean doSee) {
|
||||
return armorType == EntityEquipmentSlot.HEAD;
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == ApicultureCapabilities.ARMOR_APIARIST) {
|
||||
return capability.getDefaultInstance();
|
||||
} else if (capability == ArboricultureCapabilities.ARMOR_NATURALIST &&
|
||||
armorType == EntityEquipmentSlot.HEAD) {
|
||||
return capability.getDefaultInstance();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,17 +12,6 @@ package forestry.apiculture.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
@@ -36,6 +25,15 @@ import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister {
|
||||
private static final String iconName = "forestry:items/biomefinder";
|
||||
@@ -69,6 +67,8 @@ public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List<String> list, boolean flag) {
|
||||
super.addInformation(itemstack, player, list, flag);
|
||||
|
||||
Biome currentBiome = player.worldObj.getBiome(player.getPosition());
|
||||
|
||||
float temperatureValue = ForestryAPI.climateManager.getTemperature(player.worldObj, player.getPosition());
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
package forestry.apiculture.items;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.apiculture.ApicultureCapabilities;
|
||||
import forestry.api.apiculture.IHiveTile;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.items.ItemForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
|
||||
public class ItemSmoker extends ItemForestry implements IArmorApiarist {
|
||||
public class ItemSmoker extends ItemForestry {
|
||||
public ItemSmoker() {
|
||||
super(Tabs.tabApiculture);
|
||||
setMaxStackSize(1);
|
||||
@@ -106,14 +108,22 @@ public class ItemSmoker extends ItemForestry implements IArmorApiarist {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
tooltip.add(Translator.translateToLocal("item.for.smoker.description"));
|
||||
}
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
|
||||
return new ICapabilityProvider() {
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == ApicultureCapabilities.ARMOR_APIARIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect) {
|
||||
return true;
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == ApicultureCapabilities.ARMOR_APIARIST) {
|
||||
return capability.getDefaultInstance();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,11 @@ import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.climate.IClimateControlled;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.AlvearyBeeModifier;
|
||||
@@ -54,7 +54,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
private final InventoryBeeHousing inventory;
|
||||
private final IBeekeepingLogic beekeepingLogic;
|
||||
|
||||
private Biome cachedBiome;
|
||||
private float tempChange = 0.0f;
|
||||
private float humidChange = 0.0f;
|
||||
|
||||
@@ -381,11 +380,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
if (cachedBiome == null) {
|
||||
BlockPos coords = getReferenceCoord();
|
||||
cachedBiome = worldObj.getBiome(coords);
|
||||
}
|
||||
return cachedBiome;
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return worldObj.getBiome(coords);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,20 +13,20 @@ package forestry.apiculture.multiblock;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.network.packets.PacketActiveUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IActivatable;
|
||||
import forestry.energy.EnergyHelper;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import forestry.energy.EnergyTransferMode;
|
||||
import forestry.energy.compat.rf.IEnergyReceiverDelegated;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyReceiver, IActivatable, IAlvearyComponent.Climatiser {
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyReceiverDelegated, IActivatable, IAlvearyComponent.Climatiser {
|
||||
|
||||
private static final int WORK_CYCLES = 1;
|
||||
private static final int ENERGY_PER_OPERATION = 50;
|
||||
@@ -51,13 +51,13 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
this.definition = definition;
|
||||
|
||||
this.energyManager = new EnergyManager(1000, 2000);
|
||||
this.energyManager.setReceiveOnly();
|
||||
this.energyManager.setExternalMode(EnergyTransferMode.RECEIVE);
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
public void changeClimate(int tick, IClimateControlled climateControlled) {
|
||||
if (workingTime < 20 && energyManager.consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
if (workingTime < 20 && EnergyHelper.consumeEnergyToDoWork(energyManager, WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += ENERGY_PER_OPERATION / 10;
|
||||
}
|
||||
@@ -124,25 +124,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
}
|
||||
}
|
||||
|
||||
/* IEnergyHandler */
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) {
|
||||
return energyManager.receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from) {
|
||||
return energyManager.getEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from) {
|
||||
return energyManager.getMaxEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from) {
|
||||
return energyManager.canConnectEnergy(from);
|
||||
public EnergyManager getEnergyManager() {
|
||||
return energyManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,8 +22,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.blocks.BlockAlvearyType;
|
||||
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
|
||||
|
||||
@@ -38,7 +38,6 @@ import net.minecraft.world.biome.Biome;
|
||||
public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing, IOwnedTile, IClimatised, IGuiBeeHousingInventory, IStreamableGui {
|
||||
private final OwnerHandler ownerHandler = new OwnerHandler();
|
||||
private final IBeekeepingLogic beeLogic;
|
||||
private Biome cachedBiome;
|
||||
|
||||
// CLIENT
|
||||
private int breedingProgressPercent = 0;
|
||||
@@ -164,10 +163,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
|
||||
// / IBEEHOUSING
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
if (cachedBiome == null) {
|
||||
cachedBiome = worldObj.getBiome(getPos());
|
||||
}
|
||||
return cachedBiome;
|
||||
return worldObj.getBiome(getPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,6 +47,8 @@ import forestry.core.utils.ItemStackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -55,6 +57,7 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntitySelectors;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -65,20 +68,6 @@ import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class TileHive extends TileEntity implements ITickable, IHiveTile, IActivatable, IBeeHousing {
|
||||
private static final DamageSource damageSourceBeeHive = new DamageSourceForestry("bee.hive");
|
||||
private static final Predicate<EntityLivingBase> BEE_TARGET_PREDICATE = new Predicate<EntityLivingBase>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable EntityLivingBase input) {
|
||||
if (input != null && input.isEntityAlive() && !input.isInvisible()) {
|
||||
if (input instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) input;
|
||||
return !player.isSpectator() && !player.isCreative();
|
||||
} else if (input instanceof IMob) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@Nonnull
|
||||
private final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
|
||||
@@ -88,6 +77,9 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
private final BeekeepingLogic beeLogic;
|
||||
@Nonnull
|
||||
private final IErrorLogic errorLogic;
|
||||
@Nonnull
|
||||
private final Predicate<EntityLivingBase> beeTargetPredicate;
|
||||
|
||||
private IBee containedBee = null;
|
||||
private boolean active = false;
|
||||
private boolean angry = false;
|
||||
@@ -103,6 +95,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
inventory = new HiveBeeHousingInventory(this);
|
||||
beeLogic = new BeekeepingLogic(this);
|
||||
errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
|
||||
beeTargetPredicate = new BeeTargetPredicate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,7 +120,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
if (calmTime == 0) {
|
||||
if (canWork) {
|
||||
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
|
||||
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox, BEE_TARGET_PREDICATE);
|
||||
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox, beeTargetPredicate);
|
||||
if (!entities.isEmpty()) {
|
||||
Collections.shuffle(entities);
|
||||
EntityLivingBase entity = entities.get(0);
|
||||
@@ -371,4 +364,28 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
return getPos();
|
||||
}
|
||||
|
||||
private static class BeeTargetPredicate implements Predicate<EntityLivingBase> {
|
||||
@Nonnull
|
||||
private final IHiveTile hive;
|
||||
|
||||
public BeeTargetPredicate(@Nonnull IHiveTile hive) {
|
||||
this.hive = hive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(@Nullable EntityLivingBase input) {
|
||||
if (input != null && input.isEntityAlive() && !input.isInvisible()) {
|
||||
if (input instanceof EntityPlayer) {
|
||||
return EntitySelectors.CAN_AI_TARGET.apply(input);
|
||||
} else if (hive.isAngry()) {
|
||||
return true;
|
||||
} else if (input instanceof IMob) {
|
||||
// don't attack semi-passive vanilla mobs
|
||||
return !(input instanceof EntityEnderman) && !(input instanceof EntityPigZombie);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public enum HiveDescription implements IHiveDescription {
|
||||
}
|
||||
},
|
||||
JUNGLE(IHiveRegistry.HiveType.JUNGLE, 6.0f, BeeDefinition.TROPICAL, HiveManager.genHelper.tree()),
|
||||
END(IHiveRegistry.HiveType.END, 6.0f, BeeDefinition.ENDED, HiveManager.genHelper.ground(Blocks.END_STONE, Blocks.END_BRICKS)) {
|
||||
END(IHiveRegistry.HiveType.END, 2.0f, BeeDefinition.ENDED, HiveManager.genHelper.ground(Blocks.END_STONE, Blocks.END_BRICKS)) {
|
||||
@Override
|
||||
public boolean isGoodBiome(Biome biome) {
|
||||
return BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.END);
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
@@ -57,9 +57,8 @@ import forestry.apiculture.flowers.Flower;
|
||||
import forestry.apiculture.flowers.FlowerRegistry;
|
||||
import forestry.apiculture.tiles.TileBeeHouse;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.blocks.BlockCore;
|
||||
import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
@@ -140,9 +139,9 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
fillWithBlocks(world, structBoundingBox, 8, 1, 6, 8, 1, 10, fence, fence, false);
|
||||
fillWithBlocks(world, structBoundingBox, 2, 1, 10, 7, 1, 10, fence, fence, false);
|
||||
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
|
||||
|
||||
// Flowers
|
||||
plantFlowerGarden(world, structBoundingBox, 2, 1, 5, 7, 1, 9);
|
||||
@@ -171,7 +170,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
IBlockState slabCeiling = slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
|
||||
fillWithBlocks(world, structBoundingBox, 1, 4, 1, 7, 4, 4, slabCeiling, slabCeiling, false);
|
||||
|
||||
IBlockState logBracing = logs.withProperty(BlockArbLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
IBlockState logBracing = logs.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 1, 8, 4, 1, logBracing, logBracing, false);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 4, 8, 4, 4, logBracing, logBracing, false);
|
||||
|
||||
@@ -219,7 +218,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
// Escritoire
|
||||
if (random.nextInt(2) == 0) {
|
||||
IBlockState escritoireBlock = PluginCore.blocks.escritoire.getDefaultState().withProperty(BlockCore.FACING, EnumFacing.EAST);
|
||||
IBlockState escritoireBlock = PluginCore.blocks.escritoire.getDefaultState().withProperty(BlockBase.FACING, EnumFacing.EAST);
|
||||
setBlockState(world, escritoireBlock, 1, 1, 3, structBoundingBox);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*******************************************************************************
|
||||
* 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.arboriculture;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.arboriculture.items.ItemBlockWoodDoor;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack) {
|
||||
if(stack == null || stack.getItem() == null || stack.stackSize <= 0){
|
||||
return false;
|
||||
}
|
||||
if(stack.getItem() instanceof ItemBlockWoodDoor){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
return 0F;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile) {
|
||||
if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemBlockWoodDoor)){
|
||||
return null;
|
||||
}
|
||||
World world = camouflageHandler.getWorldObj();
|
||||
BlockPos pos = camouflageTile.getCoordinates();
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
IBlockState currentState = blockState.getActualState(world, pos);
|
||||
|
||||
ItemBlockWoodDoor itemDoor = (ItemBlockWoodDoor) stack.getItem();
|
||||
|
||||
IBlockState doorState = itemDoor.block.getDefaultState()
|
||||
.withProperty(BlockDoor.FACING, currentState.getValue(BlockDoor.FACING))
|
||||
.withProperty(BlockDoor.HINGE, currentState.getValue(BlockDoor.HINGE))
|
||||
.withProperty(BlockDoor.OPEN, currentState.getValue(BlockDoor.OPEN))
|
||||
.withProperty(BlockDoor.POWERED, currentState.getValue(BlockDoor.POWERED))
|
||||
.withProperty(BlockDoor.HALF, currentState.getValue(BlockDoor.HALF));
|
||||
|
||||
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
|
||||
return Pair.of(doorState, modelShapes.getModelForState(doorState));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@
|
||||
package forestry.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.Collection;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
@@ -27,7 +28,9 @@ import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ILeafTranslator;
|
||||
import forestry.api.genetics.ISaplingTranslator;
|
||||
@@ -39,6 +42,7 @@ import forestry.arboriculture.blocks.BlockPile;
|
||||
import forestry.arboriculture.blocks.BlockRegistryArboriculture;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
import forestry.arboriculture.blocks.slab.BlockArbSlab;
|
||||
import forestry.arboriculture.capabilities.ArmorNaturalist;
|
||||
import forestry.arboriculture.commands.CommandTree;
|
||||
import forestry.arboriculture.genetics.TreeBranchDefinition;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
@@ -53,20 +57,25 @@ import forestry.arboriculture.items.ItemCharcoal;
|
||||
import forestry.arboriculture.items.ItemGrafter;
|
||||
import forestry.arboriculture.items.ItemRegistryArboriculture;
|
||||
import forestry.arboriculture.models.TextureLeaves;
|
||||
import forestry.arboriculture.models.WoodTextures;
|
||||
import forestry.arboriculture.network.PacketRegistryArboriculture;
|
||||
import forestry.arboriculture.proxy.ProxyArboriculture;
|
||||
import forestry.arboriculture.proxy.ProxyArboricultureClient;
|
||||
import forestry.arboriculture.tiles.TileFruitPod;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.arboriculture.tiles.TilePile;
|
||||
import forestry.arboriculture.tiles.TileSapling;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.capabilities.NullStorage;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.genetics.alleles.AllelePlantType;
|
||||
import forestry.core.items.ItemFruit.EnumFruit;
|
||||
import forestry.core.network.IPacketRegistry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.IMCUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.OreDictUtil;
|
||||
@@ -87,9 +96,12 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.IFuelHandler;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
@@ -132,6 +144,9 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.hard);
|
||||
TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.hardcore);
|
||||
TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.insane);
|
||||
|
||||
// Capabilities
|
||||
CapabilityManager.INSTANCE.register(IArmorNaturalist.class, new NullStorage<>(), () -> ArmorNaturalist.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,6 +188,8 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
|
||||
// Commands
|
||||
PluginCore.rootCommand.addChildCommand(new CommandTree());
|
||||
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerArbDoor());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -409,7 +426,7 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
//Dirt Pile Block
|
||||
RecipeUtil.addShapelessRecipe(new ItemStack(PluginArboriculture.blocks.piles.get(EnumPileType.DIRT)), OreDictUtil.DUST_ASH, Items.CLAY_BALL, OreDictUtil.DUST_ASH, OreDictUtil.DIRT, OreDictUtil.DIRT, OreDictUtil.DIRT, OreDictUtil.TREE_LEAVES, Items.CLAY_BALL, OreDictUtil.TREE_LEAVES);
|
||||
RecipeUtil.addShapelessRecipe(new ItemStack(PluginArboriculture.blocks.piles.get(EnumPileType.DIRT)), PluginCore.items.fertilizerBio, Items.CLAY_BALL, PluginCore.items.fertilizerBio, OreDictUtil.DIRT, OreDictUtil.DIRT, OreDictUtil.DIRT, PluginCore.items.fertilizerBio, Items.CLAY_BALL, PluginCore.items.fertilizerBio);
|
||||
|
||||
}
|
||||
|
||||
@@ -548,9 +565,33 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites(TextureStitchEvent.Pre event) {
|
||||
TextureLeaves.registerAllSprites();
|
||||
WoodTextures.deserializeFile(Proxies.render.getSelectedTexturePack());
|
||||
for (IAlleleFruit alleleFruit : AlleleFruit.getFruitAlleles()) {
|
||||
alleleFruit.getProvider().registerSprites();
|
||||
}
|
||||
List<ResourceLocation> textures = new ArrayList<>();
|
||||
for(IWoodType type : TreeManager.woodAccess.getRegisteredWoodTypes()){
|
||||
textures.add(new ResourceLocation(type.getHeartTexture()));
|
||||
textures.add(new ResourceLocation(type.getBarkTexture()));
|
||||
textures.add(new ResourceLocation(type.getDoorLowerTexture()));
|
||||
textures.add(new ResourceLocation(type.getDoorUpperTexture()));
|
||||
textures.add(new ResourceLocation(type.getPlankTexture()));
|
||||
for(WoodBlockKind kind : WoodBlockKind.values()){
|
||||
for(Entry<String, String> loc : WoodTextures.getLocations(type, kind).entrySet()){
|
||||
textures.add(new ResourceLocation(loc.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
for(ResourceLocation loc : textures){
|
||||
TextureManager.getInstance();
|
||||
TextureManager.registerSprite(loc);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onModelBake(ModelBakeEvent event) {
|
||||
((ProxyArboricultureClient)proxy).onModelBake(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
package forestry.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
@@ -43,6 +45,7 @@ import forestry.core.utils.Log;
|
||||
|
||||
public class WoodAccess implements IWoodAccess {
|
||||
private static final Map<WoodBlockKind, WoodMap> woodMaps = new EnumMap<>(WoodBlockKind.class);
|
||||
private static final List<IWoodType> registeredWoodTypes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (WoodBlockKind woodBlockKind : WoodBlockKind.values()) {
|
||||
@@ -195,6 +198,9 @@ public class WoodAccess implements IWoodAccess {
|
||||
int meta = woodTyped.getMetaFromState(blockState);
|
||||
IWoodType woodType = woodTyped.getWoodType(meta);
|
||||
ItemStack itemStack = new ItemStack(woodTyped, 1, meta);
|
||||
if(!(woodType instanceof EnumVanillaWoodType)){
|
||||
PluginArboriculture.proxy.registerWoodModel(woodTyped, true);
|
||||
}
|
||||
register(woodType, woodBlockKind, fireproof, blockState, itemStack);
|
||||
}
|
||||
}
|
||||
@@ -207,6 +213,9 @@ public class WoodAccess implements IWoodAccess {
|
||||
IBlockState blockState = woodTyped.getDefaultState();
|
||||
IWoodType woodType = woodTyped.getWoodType(0);
|
||||
ItemStack itemStack = new ItemStack(woodTyped);
|
||||
if(!(woodType instanceof EnumVanillaWoodType)){
|
||||
PluginArboriculture.proxy.registerWoodModel(woodTyped, false);
|
||||
}
|
||||
register(woodType, woodBlockKind, fireproof, blockState, itemStack);
|
||||
}
|
||||
|
||||
@@ -218,6 +227,9 @@ public class WoodAccess implements IWoodAccess {
|
||||
throw new NullPointerException("Invalid itemStack: " + itemStack);
|
||||
}
|
||||
WoodMap woodMap = woodMaps.get(woodBlockKind);
|
||||
if(!registeredWoodTypes.contains(woodType)){
|
||||
registeredWoodTypes.add(woodType);
|
||||
}
|
||||
woodMap.getItem(fireproof).put(woodType, itemStack);
|
||||
woodMap.getBlock(fireproof).put(woodType, blockState);
|
||||
}
|
||||
@@ -249,4 +261,9 @@ public class WoodAccess implements IWoodAccess {
|
||||
}
|
||||
return blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWoodType> getRegisteredWoodTypes() {
|
||||
return registeredWoodTypes;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -14,10 +13,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodItemMeshDefinition;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.arboriculture.models.WoodModelLoader;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
@@ -50,6 +51,10 @@ public class WoodHelper {
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public static ResourceLocation getDefaultResourceLocations(IWoodTyped typed) {
|
||||
return new ResourceLocation(Constants.MOD_ID, typed.getBlockKind().toString());
|
||||
}
|
||||
|
||||
public static ResourceLocation[] getResourceLocations(IWoodTyped typed) {
|
||||
List<ResourceLocation> resourceLocations = new ArrayList<>();
|
||||
@@ -65,7 +70,7 @@ public class WoodHelper {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static class WoodMeshDefinition implements ItemMeshDefinition {
|
||||
public static class WoodMeshDefinition implements IWoodItemMeshDefinition {
|
||||
@Nonnull
|
||||
public IWoodTyped wood;
|
||||
|
||||
@@ -75,6 +80,9 @@ public class WoodHelper {
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
if(!WoodModelLoader.INSTANCE.isRegistered){
|
||||
return new ModelResourceLocation(getDefaultModelLocation(stack), "inventory");
|
||||
}
|
||||
int meta = stack.getMetadata();
|
||||
IWoodType woodType = wood.getWoodType(meta);
|
||||
WoodBlockKind blockKind = wood.getBlockKind();
|
||||
@@ -86,6 +94,12 @@ public class WoodHelper {
|
||||
throw new IllegalArgumentException("Unknown wood type: " + woodType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getDefaultModelLocation(ItemStack stack) {
|
||||
WoodBlockKind blockKind = wood.getBlockKind();
|
||||
return new ResourceLocation("forestry:item/" + blockKind.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockPlanks.EnumType;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -120,7 +119,7 @@ public class BlockForestryFenceGate<T extends Enum<T> & IWoodType> extends Block
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getDefaultResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -43,7 +42,7 @@ public class BlockForestryStairs<T extends Enum<T> & IWoodType> extends BlockSta
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getDefaultResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,19 +15,19 @@ import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodStateMapper;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.arboriculture.models.WoodModelLoader;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class WoodTypeStateMapper extends StateMapperBase {
|
||||
public class WoodTypeStateMapper extends StateMapperBase implements IWoodStateMapper {
|
||||
|
||||
@Nonnull
|
||||
private final IWoodTyped woodTyped;
|
||||
@@ -54,6 +54,11 @@ public class WoodTypeStateMapper extends StateMapperBase {
|
||||
this.propertiesToRemove.add(property);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(IBlockState state) {
|
||||
return getModelResourceLocation(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
@@ -73,11 +78,34 @@ public class WoodTypeStateMapper extends StateMapperBase {
|
||||
int meta = block.getMetaFromState(state);
|
||||
IWoodType woodType = woodTyped.getWoodType(meta);
|
||||
if (woodType instanceof EnumForestryWoodType) {
|
||||
return getForestryModelResourceLocation(woodType, properties);
|
||||
if(WoodModelLoader.INSTANCE.isRegistered){
|
||||
return getForestryModelResourceLocation(woodType, properties);
|
||||
}else{
|
||||
return getDefaultModelResourceLocation(state);
|
||||
}
|
||||
} else {
|
||||
return getVanillaModelResourceLocation(block, woodType, properties);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getDefaultModelResourceLocation(IBlockState state) {
|
||||
final Map<IProperty<?>, Comparable<?>> properties;
|
||||
if (propertyWoodType != null) {
|
||||
properties = Maps.newLinkedHashMap(state.getProperties());
|
||||
properties.remove(propertyWoodType);
|
||||
} else {
|
||||
properties = Maps.newLinkedHashMap(state.getProperties());
|
||||
}
|
||||
|
||||
for (IProperty property : propertiesToRemove) {
|
||||
properties.remove(property);
|
||||
}
|
||||
|
||||
String resourceLocation = "arboriculture/" + blockPath;
|
||||
String propertyString = this.getPropertyString(properties);
|
||||
return new ModelResourceLocation(Constants.MOD_ID + ':' + resourceLocation, propertyString);
|
||||
}
|
||||
|
||||
private ModelResourceLocation getForestryModelResourceLocation(IWoodType woodType, Map<IProperty<?>, Comparable<?>> properties) {
|
||||
String resourceLocation = "arboriculture/" + blockPath + '/' + woodType;
|
||||
|
||||
@@ -104,7 +104,7 @@ public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getDefaultResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
@@ -182,7 +181,7 @@ public abstract class BlockForestryLog<T extends Enum<T> & IWoodType> extends Bl
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public final void registerModel(Item item, IModelManager manager) {
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getDefaultResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public abstract class BlockForestryPlanks<T extends Enum<T> & IWoodType> extends
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getDefaultResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends B
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
|
||||
ModelBakery.registerItemVariants(item, WoodHelper.getDefaultResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package forestry.arboriculture.capabilities;
|
||||
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ArmorNaturalist implements IArmorNaturalist {
|
||||
public static final ArmorNaturalist INSTANCE = new ArmorNaturalist();
|
||||
|
||||
protected ArmorNaturalist() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeePollination(EntityPlayer player, ItemStack armor, boolean doSee) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package forestry.arboriculture.compat;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.items.ItemRegistryArboriculture;
|
||||
import forestry.core.utils.JeiUtil;
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
|
||||
@JEIPlugin
|
||||
public class ArboricultureJeiPlugin extends BlankModPlugin {
|
||||
@Override
|
||||
public void register(@Nonnull IModRegistry registry) {
|
||||
ItemRegistryArboriculture items = PluginArboriculture.items;
|
||||
|
||||
JeiUtil.addDescription(registry,
|
||||
items.grafter,
|
||||
items.grafterProven
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import forestry.core.gui.widgets.ItemStackWidget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -58,204 +59,213 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void drawAnalyticsPage1(GuiAlyzer gui, ItemStack itemStack) {
|
||||
ITree tree = TreeManager.treeRoot.getMember(itemStack);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
EnumGermlingType type = TreeManager.treeRoot.getType(itemStack);
|
||||
|
||||
TextLayoutHelper textLayout = gui.getTextLayout();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
{
|
||||
String customPrimaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.", "");
|
||||
String customSecondaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getSecondary().getUnlocalizedName().replace("trees.species.", "");
|
||||
|
||||
gui.drawSpeciesRow(Translator.translateToLocal("for.gui.species"), tree, EnumTreeChromosome.SPECIES, GuiAlyzer.checkCustomName(customPrimaryTreeKey), GuiAlyzer.checkCustomName(customSecondaryTreeKey));
|
||||
public void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack) {
|
||||
if(gui instanceof GuiAlyzer){
|
||||
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
|
||||
ITree tree = TreeManager.treeRoot.getMember(itemStack);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
EnumGermlingType type = TreeManager.treeRoot.getType(itemStack);
|
||||
|
||||
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
{
|
||||
String customPrimaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.", "");
|
||||
String customSecondaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getSecondary().getUnlocalizedName().replace("trees.species.", "");
|
||||
|
||||
guiAlyzer.drawSpeciesRow(Translator.translateToLocal("for.gui.species"), tree, EnumTreeChromosome.SPECIES, GuiAlyzer.checkCustomName(customPrimaryTreeKey), GuiAlyzer.checkCustomName(customSecondaryTreeKey));
|
||||
textLayout.newLine();
|
||||
}
|
||||
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.saplings"), tree, EnumTreeChromosome.FERTILITY);
|
||||
textLayout.newLineCompressed();
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.maturity"), tree, EnumTreeChromosome.MATURATION);
|
||||
textLayout.newLineCompressed();
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.height"), tree, EnumTreeChromosome.HEIGHT);
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
IAlleleInteger activeGirth = (IAlleleInteger) tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH);
|
||||
IAlleleInteger inactiveGirth = (IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.girth"), GuiAlyzer.COLUMN_0);
|
||||
guiAlyzer.drawLine(String.format("%sx%s", activeGirth.getValue(), activeGirth.getValue()), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.GIRTH, false);
|
||||
guiAlyzer.drawLine(String.format("%sx%s", inactiveGirth.getValue(), inactiveGirth.getValue()), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.GIRTH, true);
|
||||
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.yield"), tree, EnumTreeChromosome.YIELD);
|
||||
textLayout.newLineCompressed();
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS);
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.effect"), tree, EnumTreeChromosome.EFFECT);
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.saplings"), tree, EnumTreeChromosome.FERTILITY);
|
||||
textLayout.newLineCompressed();
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.maturity"), tree, EnumTreeChromosome.MATURATION);
|
||||
textLayout.newLineCompressed();
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.height"), tree, EnumTreeChromosome.HEIGHT);
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
IAlleleInteger activeGirth = (IAlleleInteger) tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH);
|
||||
IAlleleInteger inactiveGirth = (IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.girth"), GuiAlyzer.COLUMN_0);
|
||||
gui.drawLine(String.format("%sx%s", activeGirth.getValue(), activeGirth.getValue()), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.GIRTH, false);
|
||||
gui.drawLine(String.format("%sx%s", inactiveGirth.getValue(), inactiveGirth.getValue()), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.GIRTH, true);
|
||||
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.yield"), tree, EnumTreeChromosome.YIELD);
|
||||
textLayout.newLineCompressed();
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS);
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.effect"), tree, EnumTreeChromosome.EFFECT);
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void drawAnalyticsPage2(GuiAlyzer gui, ItemStack itemStack) {
|
||||
ITree tree = TreeManager.treeRoot.getMember(itemStack);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TextLayoutHelper textLayout = gui.getTextLayout();
|
||||
|
||||
textLayout.startPage();
|
||||
|
||||
int speciesDominance0 = gui.getColorCoding(tree.getGenome().getPrimary().isDominant());
|
||||
int speciesDominance1 = gui.getColorCoding(tree.getGenome().getSecondary().isDominant());
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTreeSpecies activeSpecies = (IAlleleTreeSpecies) tree.getGenome().getActiveAllele(EnumTreeChromosome.SPECIES);
|
||||
IAlleleTreeSpecies inActiveSpecies = (IAlleleTreeSpecies) tree.getGenome().getInactiveAllele(EnumTreeChromosome.SPECIES);
|
||||
|
||||
int activeCombustibility = activeSpecies.getWoodProvider().getCombustibility();
|
||||
int inactiveCombustibility = inActiveSpecies.getWoodProvider().getCombustibility();
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.combustibility"), GuiAlyzer.COLUMN_0);
|
||||
gui.drawLine(Integer.toString(activeCombustibility), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.SPECIES, false);
|
||||
gui.drawLine(Integer.toString(inactiveCombustibility), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.SPECIES, true);
|
||||
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
int activeCarbonization = activeSpecies.getWoodProvider().getCarbonization();
|
||||
int inactiveCarbonization = inActiveSpecies.getWoodProvider().getCarbonization();
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.carbonization"), GuiAlyzer.COLUMN_0);
|
||||
gui.drawLine(Integer.toString(activeCarbonization), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.SPECIES, false);
|
||||
gui.drawLine(Integer.toString(inactiveCarbonization), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.SPECIES, true);
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.native"), GuiAlyzer.COLUMN_0);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_1,
|
||||
speciesDominance0);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_2,
|
||||
speciesDominance1);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
// FRUITS
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.supports"), GuiAlyzer.COLUMN_0);
|
||||
List<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
|
||||
List<IFruitFamily> families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit());
|
||||
|
||||
int max = Math.max(families0.size(), families1.size());
|
||||
for (int i = 0; i < max; i++) {
|
||||
if (i > 0) {
|
||||
textLayout.newLineCompressed();
|
||||
public void drawAnalyticsPage2(GuiScreen gui, ItemStack itemStack) {
|
||||
if(gui instanceof GuiAlyzer){
|
||||
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
|
||||
ITree tree = TreeManager.treeRoot.getMember(itemStack);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (families0.size() > i) {
|
||||
textLayout.drawLine(families0.get(i).getName(), GuiAlyzer.COLUMN_1, speciesDominance0);
|
||||
|
||||
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
|
||||
|
||||
textLayout.startPage();
|
||||
|
||||
int speciesDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getPrimary().isDominant());
|
||||
int speciesDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getSecondary().isDominant());
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTreeSpecies activeSpecies = (IAlleleTreeSpecies) tree.getGenome().getActiveAllele(EnumTreeChromosome.SPECIES);
|
||||
IAlleleTreeSpecies inActiveSpecies = (IAlleleTreeSpecies) tree.getGenome().getInactiveAllele(EnumTreeChromosome.SPECIES);
|
||||
|
||||
int activeCombustibility = activeSpecies.getWoodProvider().getCombustibility();
|
||||
int inactiveCombustibility = inActiveSpecies.getWoodProvider().getCombustibility();
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.combustibility"), GuiAlyzer.COLUMN_0);
|
||||
guiAlyzer.drawLine(Integer.toString(activeCombustibility), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.SPECIES, false);
|
||||
guiAlyzer.drawLine(Integer.toString(inactiveCombustibility), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.SPECIES, true);
|
||||
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
int activeCarbonization = activeSpecies.getWoodProvider().getCarbonization();
|
||||
int inactiveCarbonization = inActiveSpecies.getWoodProvider().getCarbonization();
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.carbonization"), GuiAlyzer.COLUMN_0);
|
||||
guiAlyzer.drawLine(Integer.toString(activeCarbonization), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.SPECIES, false);
|
||||
guiAlyzer.drawLine(Integer.toString(inactiveCarbonization), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.SPECIES, true);
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.native"), GuiAlyzer.COLUMN_0);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_1,
|
||||
speciesDominance0);
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_2,
|
||||
speciesDominance1);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
// FRUITS
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.supports"), GuiAlyzer.COLUMN_0);
|
||||
List<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
|
||||
List<IFruitFamily> families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit());
|
||||
|
||||
int max = Math.max(families0.size(), families1.size());
|
||||
for (int i = 0; i < max; i++) {
|
||||
if (i > 0) {
|
||||
textLayout.newLineCompressed();
|
||||
}
|
||||
|
||||
if (families0.size() > i) {
|
||||
textLayout.drawLine(families0.get(i).getName(), GuiAlyzer.COLUMN_1, speciesDominance0);
|
||||
}
|
||||
if (families1.size() > i) {
|
||||
textLayout.drawLine(families1.get(i).getName(), GuiAlyzer.COLUMN_2, speciesDominance1);
|
||||
}
|
||||
|
||||
}
|
||||
if (families1.size() > i) {
|
||||
textLayout.drawLine(families1.get(i).getName(), GuiAlyzer.COLUMN_2, speciesDominance1);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
int fruitDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
|
||||
int fruitDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS).isDominant());
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.fruits"), GuiAlyzer.COLUMN_0);
|
||||
String strike = "";
|
||||
IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS);
|
||||
if (!tree.canBearFruit() && fruit0 != AlleleFruit.fruitNone) {
|
||||
strike = TextFormatting.STRIKETHROUGH.toString();
|
||||
}
|
||||
|
||||
textLayout.drawLine(strike + tree.getGenome().getFruitProvider().getDescription(), GuiAlyzer.COLUMN_1, fruitDominance0);
|
||||
|
||||
strike = "";
|
||||
IAlleleFruit fruit1 = (IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS);
|
||||
if (!tree.getGenome().getSecondary().getSuitableFruit().contains(fruit1.getProvider().getFamily()) && fruit1 != AlleleFruit.fruitNone) {
|
||||
strike = TextFormatting.STRIKETHROUGH.toString();
|
||||
}
|
||||
textLayout.drawLine(strike + fruit1.getProvider().getDescription(), GuiAlyzer.COLUMN_2, fruitDominance1);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.family"), GuiAlyzer.COLUMN_0);
|
||||
IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily();
|
||||
IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily();
|
||||
|
||||
if (primary != null) {
|
||||
textLayout.drawLine(primary.getName(), GuiAlyzer.COLUMN_1, fruitDominance0);
|
||||
}
|
||||
if (secondary != null) {
|
||||
textLayout.drawLine(secondary.getName(), GuiAlyzer.COLUMN_2, fruitDominance1);
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
int fruitDominance0 = gui.getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
|
||||
int fruitDominance1 = gui.getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS).isDominant());
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.fruits"), GuiAlyzer.COLUMN_0);
|
||||
String strike = "";
|
||||
IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS);
|
||||
if (!tree.canBearFruit() && fruit0 != AlleleFruit.fruitNone) {
|
||||
strike = TextFormatting.STRIKETHROUGH.toString();
|
||||
}
|
||||
textLayout.drawLine(strike + tree.getGenome().getFruitProvider().getDescription(), GuiAlyzer.COLUMN_1, fruitDominance0);
|
||||
|
||||
strike = "";
|
||||
IAlleleFruit fruit1 = (IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS);
|
||||
if (!tree.getGenome().getSecondary().getSuitableFruit().contains(fruit1.getProvider().getFamily()) && fruit1 != AlleleFruit.fruitNone) {
|
||||
strike = TextFormatting.STRIKETHROUGH.toString();
|
||||
}
|
||||
textLayout.drawLine(strike + fruit1.getProvider().getDescription(), GuiAlyzer.COLUMN_2, fruitDominance1);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.family"), GuiAlyzer.COLUMN_0);
|
||||
IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily();
|
||||
IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily();
|
||||
|
||||
if (primary != null) {
|
||||
textLayout.drawLine(primary.getName(), GuiAlyzer.COLUMN_1, fruitDominance0);
|
||||
}
|
||||
if (secondary != null) {
|
||||
textLayout.drawLine(secondary.getName(), GuiAlyzer.COLUMN_2, fruitDominance1);
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void drawAnalyticsPage3(GuiAlyzer gui, ItemStack itemStack) {
|
||||
ITree tree = TreeManager.treeRoot.getMember(itemStack);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TextLayoutHelper textLayout = gui.getTextLayout();
|
||||
WidgetManager widgetManager = gui.getWidgetManager();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.produce") + ":", GuiAlyzer.COLUMN_0);
|
||||
textLayout.newLine();
|
||||
|
||||
int x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : tree.getProducts().keySet()) {
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
public void drawAnalyticsPage3(GuiScreen gui, ItemStack itemStack) {
|
||||
if(gui instanceof GuiAlyzer){
|
||||
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
|
||||
ITree tree = TreeManager.treeRoot.getMember(itemStack);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.specialty") + ":", GuiAlyzer.COLUMN_0);
|
||||
textLayout.newLine();
|
||||
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : tree.getSpecialties().keySet()) {
|
||||
Proxies.common.getClientInstance().getRenderItem().renderItemIntoGUI(stack, gui.getGuiLeft() + x, gui.getGuiTop() + textLayout.getLineY());
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
|
||||
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
|
||||
WidgetManager widgetManager = guiAlyzer.getWidgetManager();
|
||||
|
||||
textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.produce") + ":", GuiAlyzer.COLUMN_0);
|
||||
textLayout.newLine();
|
||||
|
||||
int x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : tree.getProducts().keySet()) {
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.specialty") + ":", GuiAlyzer.COLUMN_0);
|
||||
textLayout.newLine();
|
||||
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
for (ItemStack stack : tree.getSpecialties().keySet()) {
|
||||
Proxies.common.getClientInstance().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY());
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = GuiAlyzer.COLUMN_0;
|
||||
textLayout.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleSpeciesRegisterEvent;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.world.ITreeGenData;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
@@ -91,6 +92,7 @@ import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSerializable {
|
||||
Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), EnumVanillaWoodType.OAK) {
|
||||
@@ -1066,6 +1068,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
}
|
||||
|
||||
public static void preInit() {
|
||||
MinecraftForge.EVENT_BUS.post(new AlleleSpeciesRegisterEvent(TreeManager.treeRoot));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package forestry.arboriculture.genetics;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.DefaultClimateProvider;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.tiles.TilePile;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.BlankItemModel;
|
||||
import forestry.core.models.BlankModel;
|
||||
import forestry.core.models.DefaultTextureGetter;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -38,7 +38,7 @@ import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ModelWoodPile extends BlankItemModel{
|
||||
public class ModelWoodPile extends BlankModel{
|
||||
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> textureGetter = new DefaultTextureGetter();
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
package forestry.arboriculture.models;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.Log;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.Variant;
|
||||
import net.minecraft.client.renderer.block.model.VariantList;
|
||||
import net.minecraft.client.renderer.block.model.WeightedBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition.MissingVariantException;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.Attributes;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.IRetexturableModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.ModelProcessingHelper;
|
||||
import net.minecraftforge.client.model.MultiModel;
|
||||
import net.minecraftforge.client.model.MultiModelState;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
public enum WoodModelLoader implements ICustomModelLoader{
|
||||
INSTANCE;
|
||||
|
||||
public static Map<ResourceLocation, Exception> loadingExceptions = Maps.newHashMap();
|
||||
private final Map<ResourceLocation, ModelBlockDefinition> blockDefinitions = Maps.newHashMap();
|
||||
public static final List<String> validFiles = new ArrayList<>();
|
||||
public boolean isRegistered = false;
|
||||
|
||||
static{
|
||||
validFiles.add("door");
|
||||
validFiles.add("double_slab");
|
||||
validFiles.add("fence");
|
||||
validFiles.add("fence_gate");
|
||||
validFiles.add("log");
|
||||
validFiles.add("planks");
|
||||
validFiles.add("slab");
|
||||
validFiles.add("stairs");
|
||||
}
|
||||
|
||||
// NOOP, handled in loader
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation){
|
||||
if(!(modelLocation instanceof ModelResourceLocation) || !modelLocation.getResourceDomain().equals(Constants.MOD_ID) || !modelLocation.getResourcePath().contains("arboriculture")){
|
||||
return false;
|
||||
}
|
||||
String path = modelLocation.getResourcePath();
|
||||
for(String validFile : validFiles){
|
||||
if(path.endsWith(validFile)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception{
|
||||
ModelResourceLocation variant = (ModelResourceLocation) modelLocation;
|
||||
ModelBlockDefinition definition = getModelBlockDefinition(variant);
|
||||
try{
|
||||
VariantList variants = definition.getVariant(variant.getVariant());
|
||||
return new WeightedRandomModel(variant, variants);
|
||||
}catch(MissingVariantException e){
|
||||
if(definition.hasMultipartData()){
|
||||
Log.error("The forestry model loader can't load the model with the location: %s, because it dons't support multipart models.", modelLocation.toString());
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/* MODEL LOADER PRIVATE METHODS */
|
||||
private ModelBlockDefinition getModelBlockDefinition(ResourceLocation location){
|
||||
try{
|
||||
ResourceLocation resourcelocation = this.getBlockstateLocation(location);
|
||||
ModelBlockDefinition modelblockdefinition = this.blockDefinitions.get(resourcelocation);
|
||||
|
||||
if (modelblockdefinition == null){
|
||||
modelblockdefinition = this.loadMultipartMBD(location, resourcelocation);
|
||||
this.blockDefinitions.put(resourcelocation, modelblockdefinition);
|
||||
}
|
||||
|
||||
return modelblockdefinition;
|
||||
}
|
||||
catch (Exception exception){
|
||||
loadingExceptions.put(location, new Exception("Could not load model definition for variant " + location, exception));
|
||||
}
|
||||
return new ModelBlockDefinition(new ArrayList<ModelBlockDefinition>());
|
||||
}
|
||||
|
||||
private ResourceLocation getBlockstateLocation(ResourceLocation location){
|
||||
return new ResourceLocation(location.getResourceDomain(), "blockstates/" + location.getResourcePath() + ".json");
|
||||
}
|
||||
|
||||
private ModelBlockDefinition loadMultipartMBD(ResourceLocation location, ResourceLocation fileIn){
|
||||
List<ModelBlockDefinition> list = Lists.<ModelBlockDefinition>newArrayList();
|
||||
|
||||
try{
|
||||
for (IResource iresource : Minecraft.getMinecraft().getResourceManager().getAllResources(fileIn)){
|
||||
list.add(this.loadModelBlockDefinition(location, iresource));
|
||||
}
|
||||
}catch (IOException ioexception){
|
||||
throw new RuntimeException("Encountered an exception when loading model definition of model " + fileIn, ioexception);
|
||||
}
|
||||
|
||||
return new ModelBlockDefinition(list);
|
||||
}
|
||||
|
||||
private ModelBlockDefinition loadModelBlockDefinition(ResourceLocation location, IResource iresource){
|
||||
InputStream inputstream = null;
|
||||
ModelBlockDefinition definition;
|
||||
|
||||
try{
|
||||
inputstream = iresource.getInputStream();
|
||||
definition = ModelBlockDefinition.parseFromReader(new InputStreamReader(inputstream, Charsets.UTF_8));
|
||||
}catch (Exception exception){
|
||||
throw new RuntimeException("Encountered an exception when loading model definition of \'" + location + "\' from: \'" + iresource.getResourceLocation() + "\' in resourcepack: \'" + iresource.getResourcePackName() + "\'", exception);
|
||||
}finally{
|
||||
IOUtils.closeQuietly(inputstream);
|
||||
}
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
||||
private class WeightedRandomModel implements IRetexturableModel {
|
||||
private final List<Variant> variants;
|
||||
private final List<ResourceLocation> locations = new ArrayList<ResourceLocation>();
|
||||
private final Set<ResourceLocation> textures = Sets.newHashSet();
|
||||
private final List<IModel> models = new ArrayList<IModel>();
|
||||
private final IModelState defaultState;
|
||||
|
||||
public WeightedRandomModel(List<ResourceLocation> locations, List<IModel> models, List<Variant> variants, IModelState defaultState){
|
||||
this.locations.addAll(locations);
|
||||
this.models.addAll(models);
|
||||
this.variants = variants;
|
||||
this.defaultState = defaultState;
|
||||
for(IModel model : models){
|
||||
textures.addAll(model.getTextures());
|
||||
}
|
||||
}
|
||||
|
||||
public WeightedRandomModel(ResourceLocation parent, VariantList variants) throws Exception{
|
||||
this.variants = variants.getVariantList();
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
for (Variant v : this.variants){
|
||||
ResourceLocation loc = v.getModelLocation();
|
||||
locations.add(loc);
|
||||
|
||||
/*
|
||||
* Vanilla eats this, which makes it only show variants that have models.
|
||||
* But that doesn't help debugging, so throw the exception
|
||||
*/
|
||||
IModel model;
|
||||
if(loc.equals(new ModelResourceLocation("builtin/missing", "missing"))){
|
||||
// explicit missing location, happens if blockstate has "model"=null
|
||||
model = ModelLoaderRegistry.getMissingModel();
|
||||
}else{
|
||||
model = ModelLoaderRegistry.getModel(loc);
|
||||
}
|
||||
|
||||
// FIXME: is this the place? messes up dependency and texture resolution
|
||||
model = v.process(model);
|
||||
for(ResourceLocation location : model.getDependencies()){
|
||||
ModelLoaderRegistry.getModelOrMissing(location);
|
||||
}
|
||||
//FMLLog.getLogger().error("Exception resolving indirect dependencies for model" + loc, e);
|
||||
textures.addAll(model.getTextures()); // Kick this, just in case.
|
||||
|
||||
models.add(model);
|
||||
builder.add(Pair.of(model, v.getState()));
|
||||
}
|
||||
|
||||
if (models.size() == 0){ //If all variants are missing, add one with the missing model and default rotation.
|
||||
// FIXME: log this?
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
models.add(missing);
|
||||
builder.add(Pair.<IModel, IModelState>of(missing, TRSRTransformation.identity()));
|
||||
}
|
||||
|
||||
defaultState = new MultiModelState(builder.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies(){
|
||||
return ImmutableList.copyOf(locations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures(){
|
||||
return ImmutableSet.copyOf(textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter){
|
||||
if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)){
|
||||
throw new IllegalArgumentException("can't bake vanilla weighted models to the format that doesn't fit into the default one: " + format);
|
||||
}
|
||||
if(variants.size() == 1){
|
||||
IModel model = models.get(0);
|
||||
return model.bake(MultiModelState.getPartState(state, model, 0), format, bakedTextureGetter);
|
||||
}
|
||||
WeightedBakedModel.Builder builder = new WeightedBakedModel.Builder();
|
||||
for(int i = 0; i < variants.size(); i++){
|
||||
IModel model = models.get(i);
|
||||
builder.add(model.bake(MultiModelState.getPartState(state, model, i), format, bakedTextureGetter), variants.get(i).getWeight());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState(){
|
||||
return defaultState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel retexture(ImmutableMap<String, String> textures) {
|
||||
List<IModel> models = new ArrayList<IModel>();
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
for (Variant v : this.variants){
|
||||
try{
|
||||
ResourceLocation loc = v.getModelLocation();
|
||||
locations.add(loc);
|
||||
|
||||
IModel model;
|
||||
if(loc.equals(new ModelResourceLocation("builtin/missing", "missing"))){
|
||||
model = ModelLoaderRegistry.getMissingModel();
|
||||
}else{
|
||||
model = ModelLoaderRegistry.getModel(loc);
|
||||
}
|
||||
|
||||
model = v.process(model);
|
||||
for(ResourceLocation location : model.getDependencies()){
|
||||
ModelLoaderRegistry.getModelOrMissing(location);
|
||||
}
|
||||
|
||||
if(model instanceof MultiModel){
|
||||
IModel base = ObfuscationReflectionHelper.getPrivateValue(MultiModel.class, (MultiModel)model, 1);
|
||||
Map<String, Pair<IModel, IModelState>> parts = ObfuscationReflectionHelper.getPrivateValue(MultiModel.class, (MultiModel)model, 3);
|
||||
|
||||
ImmutableMap.Builder<String, Pair<IModel, IModelState>> partBuilder = new ImmutableMap.Builder<>();
|
||||
IModel retexturedModel = ModelProcessingHelper.retexture(base, textures);
|
||||
for(Entry<String, Pair<IModel, IModelState>> part : parts.entrySet()){
|
||||
partBuilder.put(part.getKey(), Pair.of(ModelProcessingHelper.retexture(part.getValue().getLeft(), textures), part.getValue().getRight()));
|
||||
}
|
||||
|
||||
ObfuscationReflectionHelper.setPrivateValue(MultiModel.class, (MultiModel)model, retexturedModel, 1);
|
||||
ObfuscationReflectionHelper.setPrivateValue(MultiModel.class, (MultiModel)model, partBuilder.build(), 3);
|
||||
}
|
||||
model = ModelProcessingHelper.retexture(model, textures);
|
||||
|
||||
models.add(model);
|
||||
builder.add(Pair.of(model, v.getState()));
|
||||
}catch(Exception e){}
|
||||
}
|
||||
|
||||
if (models.size() == 0){
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
models.add(missing);
|
||||
builder.add(Pair.<IModel, IModelState>of(missing, TRSRTransformation.identity()));
|
||||
}
|
||||
return new WeightedRandomModel(locations, models, variants, new MultiModelState(builder.build()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package forestry.arboriculture.models;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class WoodTextures {
|
||||
|
||||
public static final Gson GSON = new GsonBuilder().create();
|
||||
protected static final Map<String, Texture> textures = new HashMap<>();
|
||||
|
||||
public static void deserializeFile(IResourceManager resourceManager){
|
||||
try {
|
||||
InputStream stream = resourceManager.getResource(new ResourceLocation("forestry:textures/woodTextures.json")).getInputStream();
|
||||
if(stream != null){
|
||||
JsonReader reader = null;
|
||||
try {
|
||||
reader = new JsonReader(new BufferedReader(new InputStreamReader(stream)));
|
||||
JsonElement json = Streams.parse(reader);
|
||||
if(json.isJsonObject()){
|
||||
for(Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()){
|
||||
JsonElement ele = entry.getValue();
|
||||
if(ele.isJsonObject()){
|
||||
textures.put(entry.getKey(), loadTexture(ele.getAsJsonObject()));
|
||||
}else if(ele.isJsonArray()){
|
||||
ImmutableMap.Builder<String, SimpleTexture> locations = new ImmutableMap.Builder<>();
|
||||
for(JsonElement eleEntry : ele.getAsJsonArray()){
|
||||
if(eleEntry.isJsonObject()){
|
||||
JsonObject obj = eleEntry.getAsJsonObject();
|
||||
if(!obj.has("kind") || !obj.get("kind").isJsonPrimitive() || !obj.get("kind").getAsJsonPrimitive().isString()){
|
||||
continue;
|
||||
}
|
||||
String kind = obj.get("kind").getAsString();
|
||||
locations.put(kind, loadTexture(obj));
|
||||
}
|
||||
}
|
||||
textures.put(entry.getKey(), new KindTexture(locations.build()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}finally{
|
||||
if(reader != null){
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if(!(e instanceof FileNotFoundException)){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static SimpleTexture loadTexture(JsonObject obj){
|
||||
ImmutableMap.Builder<String, String> locations = new ImmutableMap.Builder<>();
|
||||
for(Entry<String, JsonElement> eleEntry : obj.entrySet()){
|
||||
JsonElement e = eleEntry.getValue();
|
||||
if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isString()){
|
||||
locations.put(eleEntry.getKey(), e.getAsString());
|
||||
}
|
||||
}
|
||||
return new SimpleTexture(locations.build());
|
||||
}
|
||||
|
||||
public static ImmutableMap<String, String> getLocations(IWoodType woodType, WoodBlockKind blockKind){
|
||||
if(woodType != null && blockKind != null && woodType.getName() != null){
|
||||
String kindName = blockKind.toString();
|
||||
Texture kindTex = textures.get(blockKind);
|
||||
Texture tex = textures.get(woodType.getName().toLowerCase(Locale.ENGLISH));
|
||||
Map<String, String> locations = new HashMap<>();
|
||||
if(kindTex != null && kindTex instanceof SimpleTexture){
|
||||
locations.putAll(((SimpleTexture)kindTex).locations);
|
||||
}
|
||||
if(tex != null){
|
||||
if(tex instanceof SimpleTexture){
|
||||
locations.putAll(((SimpleTexture) tex).locations);
|
||||
}else{
|
||||
SimpleTexture kind = ((KindTexture)tex).kindLocations.get(kindName);
|
||||
locations.putAll(kind.locations);
|
||||
}
|
||||
}
|
||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();
|
||||
for(Entry<String, String> location : locations.entrySet()){
|
||||
String texture = location.getValue();
|
||||
if(texture.equals("plank")){
|
||||
texture = woodType.getPlankTexture();
|
||||
}else if(texture.equals("bark")){
|
||||
texture = woodType.getBarkTexture();
|
||||
}else if(texture.equals("heart")){
|
||||
texture = woodType.getHeartTexture();
|
||||
}else if(texture.equals("doorUp")){
|
||||
texture = woodType.getDoorUpperTexture();
|
||||
}else if(texture.equals("doorLow")){
|
||||
texture = woodType.getDoorLowerTexture();
|
||||
}else{
|
||||
builder.put(location.getKey(), texture.replace("%woodType", woodType.getName().toLowerCase(Locale.ENGLISH)));
|
||||
continue;
|
||||
}
|
||||
builder.put(location.getKey(), texture);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
|
||||
private static class Texture{
|
||||
|
||||
}
|
||||
|
||||
private static class SimpleTexture extends Texture{
|
||||
public final ImmutableMap<String, String> locations;
|
||||
|
||||
public SimpleTexture(ImmutableMap<String, String> locations) {
|
||||
this.locations = locations;
|
||||
}
|
||||
}
|
||||
|
||||
private static class KindTexture extends Texture{
|
||||
public final ImmutableMap<String, SimpleTexture> kindLocations;
|
||||
|
||||
public KindTexture(ImmutableMap<String, SimpleTexture> kindLocations) {
|
||||
this.kindLocations = kindLocations;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.proxy;
|
||||
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ProxyArboriculture {
|
||||
|
||||
public void initializeModels() {
|
||||
@@ -26,5 +29,7 @@ public class ProxyArboriculture {
|
||||
public int getFoliageColorPine() {
|
||||
return 6396257;
|
||||
}
|
||||
|
||||
|
||||
public <T extends Block & IWoodTyped> void registerWoodModel(T woodTyped, boolean withVariants){
|
||||
}
|
||||
}
|
||||
@@ -10,28 +10,64 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.proxy;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.BlockStateMapper;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.world.ColorizerFoliage;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import forestry.api.arboriculture.EnumPileType;
|
||||
import forestry.api.arboriculture.IWoodItemMeshDefinition;
|
||||
import forestry.api.arboriculture.IWoodStateMapper;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.blocks.BlockDecorativeLeaves;
|
||||
import forestry.arboriculture.blocks.slab.BlockArbSlab;
|
||||
import forestry.arboriculture.models.ModelDecorativeLeaves;
|
||||
import forestry.arboriculture.models.ModelLeaves;
|
||||
import forestry.arboriculture.models.ModelWoodPile;
|
||||
import forestry.arboriculture.models.WoodModelLoader;
|
||||
import forestry.arboriculture.models.WoodTextures;
|
||||
import forestry.arboriculture.render.CharcoalPileRenderer;
|
||||
import forestry.arboriculture.tiles.TilePile;
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.models.BlockModelEntry;
|
||||
import forestry.core.models.SimpleRetexturedModel;
|
||||
import forestry.core.models.WoodModelEntry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ProxyArboricultureClient extends ProxyArboriculture {
|
||||
private static Set<WoodModelEntry> woodModelEntrys = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void initializeModels() {
|
||||
{
|
||||
ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:leaves");
|
||||
ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:leaves", "inventory");
|
||||
BlockModelIndex blockModelIndex = new BlockModelIndex(blockModelLocation, itemModelLocation, new ModelLeaves(), PluginArboriculture.blocks.leaves);
|
||||
BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelLeaves(), PluginArboriculture.blocks.leaves);
|
||||
Proxies.render.registerBlockModel(blockModelIndex);
|
||||
}
|
||||
|
||||
@@ -39,17 +75,89 @@ public class ProxyArboricultureClient extends ProxyArboriculture {
|
||||
String resourceName = "forestry:leaves.decorative." + leaves.getBlockNumber();
|
||||
ModelResourceLocation blockModelLocation = new ModelResourceLocation(resourceName);
|
||||
ModelResourceLocation itemModeLocation = new ModelResourceLocation(resourceName, "inventory");
|
||||
BlockModelIndex blockModelIndex = new BlockModelIndex(blockModelLocation, itemModeLocation, new ModelDecorativeLeaves(), leaves);
|
||||
BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModeLocation, new ModelDecorativeLeaves(), leaves);
|
||||
Proxies.render.registerBlockModel(blockModelIndex);
|
||||
}
|
||||
|
||||
{
|
||||
ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:pile", "type=wood");
|
||||
ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:woodPile", "inventory");
|
||||
BlockModelIndex blockModelIndex = new BlockModelIndex(blockModelLocation, itemModelLocation, new ModelWoodPile(), PluginArboriculture.blocks.piles.get(EnumPileType.WOOD));
|
||||
BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelWoodPile(), PluginArboriculture.blocks.piles.get(EnumPileType.WOOD));
|
||||
Proxies.render.registerBlockModel(blockModelIndex);
|
||||
}
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePile.class, new CharcoalPileRenderer());
|
||||
ModelLoaderRegistry.registerLoader(WoodModelLoader.INSTANCE);
|
||||
for(BlockArbSlab slab : PluginArboriculture.blocks.slabsDouble){
|
||||
registerWoodModel(slab, true);
|
||||
}
|
||||
for(BlockArbSlab slab : PluginArboriculture.blocks.slabsDoubleFireproof){
|
||||
registerWoodModel(slab, true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public <T extends Block & IWoodTyped> void onModelBake(ModelBakeEvent event){
|
||||
WoodModelLoader.INSTANCE.isRegistered = true;
|
||||
IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
|
||||
Minecraft minecraft = Proxies.common.getClientInstance();
|
||||
Map<ResourceLocation, Exception> loadingExceptions = ObfuscationReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), 2);
|
||||
|
||||
if(minecraft.getBlockRendererDispatcher() != null){
|
||||
BlockStateMapper stateMapper = minecraft.getBlockRendererDispatcher().getBlockModelShapes().getBlockStateMapper();
|
||||
Map<Item, ItemMeshDefinition> definitions = ObfuscationReflectionHelper.getPrivateValue(ItemModelMesher.class, minecraft.getRenderItem().getItemModelMesher(), 2);
|
||||
Map<Block, IStateMapper> blockStateMap = ObfuscationReflectionHelper.getPrivateValue(BlockStateMapper.class, stateMapper, 0);
|
||||
|
||||
for(WoodModelEntry<T> entry : woodModelEntrys){
|
||||
T woodTyped = entry.woodTyped;
|
||||
WoodBlockKind woodKind = woodTyped.getBlockKind();
|
||||
|
||||
IStateMapper mapper = blockStateMap.get(woodTyped);
|
||||
if(mapper instanceof IWoodStateMapper){
|
||||
IWoodStateMapper woodMapper = (IWoodStateMapper) mapper;
|
||||
try{
|
||||
for(IBlockState state : woodTyped.getBlockState().getValidStates()) {
|
||||
IWoodType woodType;
|
||||
ItemStack itemStack;
|
||||
if(entry.withVariants){
|
||||
int meta = woodTyped.getMetaFromState(state);
|
||||
woodType = woodTyped.getWoodType(meta);
|
||||
itemStack = new ItemStack(woodTyped, 1, meta);
|
||||
}else{
|
||||
woodType = woodTyped.getWoodType(0);
|
||||
itemStack = new ItemStack(woodTyped);
|
||||
}
|
||||
ImmutableMap<String, String> customTextures = WoodTextures.getLocations(woodType, woodKind);
|
||||
if(woodKind.retextureItem){
|
||||
ItemMeshDefinition definition = definitions.get(itemStack.getItem());
|
||||
if(definition instanceof IWoodItemMeshDefinition){
|
||||
IWoodItemMeshDefinition woodDefinition = (IWoodItemMeshDefinition) definition;
|
||||
IModel basicItemModel = ModelLoaderRegistry.getModel(woodDefinition.getDefaultModelLocation(itemStack));
|
||||
ModelResourceLocation basicItemLocation = definition.getModelLocation(itemStack);
|
||||
|
||||
registry.putObject(basicItemLocation, new SimpleRetexturedModel(woodKind.retextureModel(basicItemModel, woodType, customTextures)));
|
||||
}
|
||||
}
|
||||
IModel basicModel = ModelLoaderRegistry.getModel(woodMapper.getDefaultModelResourceLocation(state));
|
||||
ModelResourceLocation basicLocation = woodMapper.getModelLocation(state);
|
||||
if(loadingExceptions.containsKey(basicLocation)){
|
||||
loadingExceptions.remove(basicLocation);
|
||||
}
|
||||
registry.putObject(basicLocation, new SimpleRetexturedModel(woodKind.retextureModel(basicModel, woodType, customTextures)));
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadingExceptions.putAll(WoodModelLoader.loadingExceptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Block & IWoodTyped> void registerWoodModel(T woodTyped, boolean withVariants){
|
||||
woodModelEntrys.add(new WoodModelEntry(woodTyped, withVariants));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loaded 100 of 1344 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user