mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41ab1ea374 | ||
|
|
52b8d56ff0 | ||
|
|
a61879daff | ||
|
|
e71edd5855 | ||
|
|
321e316665 | ||
|
|
aca6ed1fd8 | ||
|
|
b135593733 | ||
|
|
ac7fe4b2d2 | ||
|
|
5e0e045053 | ||
|
|
f01dab6f58 | ||
|
|
9385a4caca | ||
|
|
582c8d64df | ||
|
|
26c40b2006 | ||
|
|
b7eaaf6804 | ||
|
|
3f07e68952 | ||
|
|
2b40762934 | ||
|
|
dcaf6e144f | ||
|
|
413e1b9a0d | ||
|
|
64f64f2b5c | ||
|
|
2d25754731 | ||
|
|
2df6cfb7f7 | ||
|
|
2d0ca49359 | ||
|
|
d567138365 | ||
|
|
72380251f3 | ||
|
|
05a263826e | ||
|
|
61aa8bdcf0 | ||
|
|
e0694842b6 | ||
|
|
ff9942d0bc | ||
|
|
dcf7776cc1 | ||
|
|
a0d355d0aa | ||
|
|
649a061b6e | ||
|
|
2ca743a931 | ||
|
|
76a34a603b | ||
|
|
68651939e7 | ||
|
|
9dcc818a17 |
No files matched your search
+1
-1
@@ -8,4 +8,4 @@ ic2_version=2.6.76-ex110
|
||||
|
||||
version_major=5
|
||||
version_minor=2
|
||||
version_patch=14
|
||||
version_patch=15
|
||||
+1
-1
Submodule lang updated: a31d99f6f6...6a30635d3f.
@@ -10,53 +10,51 @@ import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public enum EnumForestryWoodType implements IWoodType {
|
||||
LARCH(4, 20),
|
||||
TEAK(4, 20),
|
||||
ACACIA(4, 20),
|
||||
LIME(4, 19),
|
||||
CHESTNUT(4, 21),
|
||||
WENGE(4, 20),
|
||||
BAOBAB(4, 20),
|
||||
SEQUOIA(3, 18, 4.0f),
|
||||
LARCH(4),
|
||||
TEAK(4),
|
||||
ACACIA(4),
|
||||
LIME(4),
|
||||
CHESTNUT(4),
|
||||
WENGE(4),
|
||||
BAOBAB(4),
|
||||
SEQUOIA(3, 4.0f),
|
||||
|
||||
KAPOK(4, 20),
|
||||
EBONY(4, 20),
|
||||
MAHOGANY(4, 20),
|
||||
BALSA(4, 20, 1.0f),
|
||||
WILLOW(4, 20),
|
||||
WALNUT(4, 21),
|
||||
GREENHEART(4, 20, 7.5f),
|
||||
CHERRY(4, 20),
|
||||
KAPOK(4),
|
||||
EBONY(4),
|
||||
MAHOGANY(4),
|
||||
BALSA(4, 1.0f),
|
||||
WILLOW(4),
|
||||
WALNUT(4),
|
||||
GREENHEART(4, 7.5f),
|
||||
CHERRY(4),
|
||||
|
||||
MAHOE(4, 20),
|
||||
POPLAR(4, 20),
|
||||
PALM(4, 20),
|
||||
PAPAYA(4, 20),
|
||||
PINE(4, 20, 3.0f),
|
||||
PLUM(4, 20),
|
||||
MAPLE(4, 20),
|
||||
CITRUS(4, 20),
|
||||
MAHOE(4),
|
||||
POPLAR(4),
|
||||
PALM(4),
|
||||
PAPAYA(4),
|
||||
PINE(4, 3.0f),
|
||||
PLUM(4),
|
||||
MAPLE(4),
|
||||
CITRUS(4),
|
||||
|
||||
GIGANTEUM(3, 18, 4.0f),
|
||||
IPE(4, 20),
|
||||
PADAUK(4, 20),
|
||||
COCOBOLO(4, 20),
|
||||
ZEBRAWOOD(4, 20);
|
||||
GIGANTEUM(3, 4.0f),
|
||||
IPE(4),
|
||||
PADAUK(4),
|
||||
COCOBOLO(4),
|
||||
ZEBRAWOOD(4);
|
||||
|
||||
public static final float DEFAULT_HARDNESS = 2.0f;
|
||||
public static final EnumForestryWoodType[] VALUES = values();
|
||||
|
||||
private final int carbonization;
|
||||
private final int combustability;
|
||||
private final float hardness;
|
||||
|
||||
EnumForestryWoodType(int carbonization, int combustability) {
|
||||
this(carbonization, combustability, DEFAULT_HARDNESS);
|
||||
EnumForestryWoodType(int carbonization) {
|
||||
this(carbonization, DEFAULT_HARDNESS);
|
||||
}
|
||||
|
||||
EnumForestryWoodType(int carbonization, int combustability, float hardness) {
|
||||
EnumForestryWoodType(int carbonization, float hardness) {
|
||||
this.carbonization = carbonization;
|
||||
this.combustability = combustability;
|
||||
this.hardness = hardness;
|
||||
}
|
||||
|
||||
@@ -96,10 +94,17 @@ public enum EnumForestryWoodType implements IWoodType {
|
||||
public int getCarbonization() {
|
||||
return carbonization;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCombustability() {
|
||||
return combustability;
|
||||
public float getCharcoalChance(int numberOfCharcoal) {
|
||||
if(numberOfCharcoal == 3){
|
||||
return 0.75F;
|
||||
}else if(numberOfCharcoal == 4){
|
||||
return 0.5F;
|
||||
}else if(numberOfCharcoal == 5){
|
||||
return 0.25F;
|
||||
}
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,12 +7,12 @@ import java.util.Random;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
|
||||
public enum EnumVanillaWoodType implements IWoodType {
|
||||
OAK(BlockPlanks.EnumType.OAK, 5, 20),
|
||||
SPRUCE(BlockPlanks.EnumType.SPRUCE, 4, 19),
|
||||
BIRCH(BlockPlanks.EnumType.BIRCH, 4, 19),
|
||||
JUNGLE(BlockPlanks.EnumType.JUNGLE, 5, 20),
|
||||
ACACIA(BlockPlanks.EnumType.ACACIA, 4, 20),
|
||||
DARK_OAK(BlockPlanks.EnumType.DARK_OAK, 5, 20);
|
||||
OAK(BlockPlanks.EnumType.OAK, 5),
|
||||
SPRUCE(BlockPlanks.EnumType.SPRUCE, 4),
|
||||
BIRCH(BlockPlanks.EnumType.BIRCH, 4),
|
||||
JUNGLE(BlockPlanks.EnumType.JUNGLE, 5),
|
||||
ACACIA(BlockPlanks.EnumType.ACACIA, 4),
|
||||
DARK_OAK(BlockPlanks.EnumType.DARK_OAK, 5);
|
||||
|
||||
public static final EnumVanillaWoodType[] VALUES = values();
|
||||
|
||||
@@ -22,12 +22,10 @@ public enum EnumVanillaWoodType implements IWoodType {
|
||||
|
||||
private final BlockPlanks.EnumType vanillaType;
|
||||
private final int carbonization;
|
||||
private final int combustability;
|
||||
|
||||
EnumVanillaWoodType(BlockPlanks.EnumType vanillaType, int carbonization, int combustability) {
|
||||
EnumVanillaWoodType(BlockPlanks.EnumType vanillaType, int carbonization) {
|
||||
this.vanillaType = vanillaType;
|
||||
this.carbonization = carbonization;
|
||||
this.combustability = combustability;
|
||||
}
|
||||
|
||||
public BlockPlanks.EnumType getVanillaType() {
|
||||
@@ -66,10 +64,17 @@ public enum EnumVanillaWoodType implements IWoodType {
|
||||
public int getCarbonization() {
|
||||
return carbonization;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCombustability() {
|
||||
return combustability;
|
||||
public float getCharcoalChance(int numberOfCharcoal) {
|
||||
if(numberOfCharcoal == 3){
|
||||
return 0.75F;
|
||||
}else if(numberOfCharcoal == 4){
|
||||
return 0.5F;
|
||||
}else if(numberOfCharcoal == 5){
|
||||
return 0.25F;
|
||||
}
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,13 +31,13 @@ public interface IWoodProvider {
|
||||
*/
|
||||
ItemStack getWoodStack();
|
||||
|
||||
/**
|
||||
* @return how long this wood's charcoal burns / 1000
|
||||
*/
|
||||
int getCombustibility();
|
||||
|
||||
/**
|
||||
* The amount of charcoal dropped from a charcoal pile of this wood.
|
||||
*/
|
||||
int getCarbonization();
|
||||
|
||||
/**
|
||||
* The chance that a pile has to drop a extra charcoal
|
||||
*/
|
||||
float getCharcoalChance(int numberOfCharcoal);
|
||||
}
|
||||
@@ -12,8 +12,8 @@ public interface IWoodType extends IStringSerializable {
|
||||
float getHardness();
|
||||
|
||||
int getCarbonization();
|
||||
|
||||
int getCombustability();
|
||||
|
||||
float getCharcoalChance(int numberOfCharcoal);
|
||||
|
||||
String getPlankTexture();
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ public interface IClimateManager {
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
@Nonnull
|
||||
IClimateProvider getDefaultClimate(World world, BlockPos pos);
|
||||
|
||||
void addRegion(IClimateRegion region);
|
||||
@@ -30,6 +31,9 @@ public interface IClimateManager {
|
||||
|
||||
void removeSource(IClimateSourceProvider source);
|
||||
|
||||
@Nullable
|
||||
IClimatePosition getPosition(World world, BlockPos pos);
|
||||
|
||||
@Nullable
|
||||
IClimateRegion getRegionForPos(World world, BlockPos pos);
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ public interface ICamouflageAccess {
|
||||
|
||||
void addItemToBlackList(@Nonnull String type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
void addModIdToBlackList(@Nonnull String type, @Nonnull String modID);
|
||||
|
||||
boolean isItemBlackListed(@Nonnull String type, @Nonnull ItemStack camouflageBlock);
|
||||
|
||||
ICamouflageItemHandler getHandlerFromItem(ItemStack stack);
|
||||
|
||||
@@ -26,6 +26,7 @@ public interface ICamouflageHandler extends ILocatable {
|
||||
|
||||
/**
|
||||
* Set the camouflage block item for the type.
|
||||
* @return True if the block has chanced.
|
||||
*/
|
||||
void setCamouflageBlock(String type, ItemStack camouflageBlock);
|
||||
boolean setCamouflageBlock(String type, ItemStack camouflageBlock, boolean sendClientUpdate);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
|
||||
|
||||
private static List<IHiveDrop> getDropsForHive(int meta) {
|
||||
String hiveName = getHiveNameForMeta(meta);
|
||||
if (hiveName == null) {
|
||||
if (hiveName == null || hiveName.equals(HiveType.SWARM.getHiveUid())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return PluginApiculture.hiveRegistry.getDrops(hiveName);
|
||||
|
||||
@@ -34,7 +34,7 @@ public enum BlockTypeApicultureTesr implements IBlockTypeTesr {
|
||||
private final IMachinePropertiesTesr<?> machineProperties;
|
||||
|
||||
<T extends TileForestry> BlockTypeApicultureTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, AxisAlignedBB boundingBox) {
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0", false);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forestry.apiculture.compat;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
@@ -13,10 +12,23 @@ import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.ISubtypeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@JEIPlugin
|
||||
public class ApicultureJeiPlugin extends BlankModPlugin {
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
|
||||
ItemRegistryApiculture items = PluginApiculture.items;
|
||||
|
||||
ISubtypeRegistry.ISubtypeInterpreter beeSubtypeInterpreter = itemStack -> {
|
||||
IAlleleSpecies species = Genome.getSpeciesDirectly(BeeManager.beeRoot, itemStack);
|
||||
return species == null ? null : species.getUID();
|
||||
};
|
||||
|
||||
subtypeRegistry.registerNbtInterpreter(items.beeDroneGE, beeSubtypeInterpreter);
|
||||
subtypeRegistry.registerNbtInterpreter(items.beePrincessGE, beeSubtypeInterpreter);
|
||||
subtypeRegistry.registerNbtInterpreter(items.beeQueenGE, beeSubtypeInterpreter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(@Nonnull IModRegistry registry) {
|
||||
ItemRegistryApiculture items = PluginApiculture.items;
|
||||
@@ -39,21 +51,5 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
|
||||
items.scoop,
|
||||
items.imprinter
|
||||
);
|
||||
|
||||
ISubtypeRegistry subtypeRegistry = registry.getJeiHelpers().getSubtypeRegistry();
|
||||
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 {
|
||||
public static BeeSubtypeInterpreter INSTANCE = new BeeSubtypeInterpreter();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSubtypeInfo(@Nonnull ItemStack itemStack) {
|
||||
IAlleleSpecies species = Genome.getSpeciesDirectly(BeeManager.beeRoot, itemStack);
|
||||
return species == null ? null : species.getUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,6 @@ import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorState;
|
||||
|
||||
@@ -180,7 +180,7 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public IBee getMember(ItemStack stack) {
|
||||
if (!isMember(stack)) {
|
||||
if (!isMember(stack) || !stack.hasTagCompound()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import forestry.apiculture.gui.widgets.HabitatSlot;
|
||||
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, ItemInventoryHabitatLocator> {
|
||||
@@ -85,7 +86,7 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
String str = Translator.translateToLocal("item.for.habitatLocator.name").toUpperCase();
|
||||
fontRendererObj.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
// Set active according to valid biomes.
|
||||
Set<BiomeDictionary.Type> activeBiomeTypes = EnumSet.noneOf(BiomeDictionary.Type.class);
|
||||
|
||||
@@ -28,6 +28,7 @@ import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiUtil;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryImprinter> {
|
||||
@@ -58,19 +59,19 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryI
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
int offset = (138 - fontRendererObj.getStringWidth(Translator.translateToLocal("for.gui.imprinter.name"))) / 2;
|
||||
fontRendererObj.drawString(Translator.translateToLocal("for.gui.imprinter.name"), startX + 8 + offset, startY + 16, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(Translator.translateToLocal("for.gui.imprinter.name"), startX + 8 + offset, startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
IAlleleBeeSpecies primary = inventory.getPrimary();
|
||||
drawBeeSpeciesIcon(primary, startX + 12, startY + 32);
|
||||
fontRendererObj.drawString(primary.getName(), startX + 32, startY + 36, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(primary.getName(), startX + 32, startY + 36, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
IAlleleBeeSpecies secondary = inventory.getSecondary();
|
||||
drawBeeSpeciesIcon(secondary, startX + 12, startY + 52);
|
||||
fontRendererObj.drawString(secondary.getName(), startX + 32, startY + 56, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(secondary.getName(), startX + 32, startY + 56, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
String youCheater = Translator.translateToLocal("for.gui.imprinter.cheater");
|
||||
offset = (138 - fontRendererObj.getStringWidth(youCheater)) / 2;
|
||||
fontRendererObj.drawString(youCheater, startX + 8 + offset, startY + 76, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(youCheater, startX + 8 + offset, startY + 76, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.climate.IClimateControlled;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
@@ -39,6 +40,7 @@ import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.ClimateUtil;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -425,6 +427,10 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
data.writeVarInt(beekeepingLogic.getBeeProgressPercent());
|
||||
data.writeVarInt(Math.round(tempChange * 100));
|
||||
data.writeVarInt(Math.round(humidChange * 100));
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getReferenceCoord());
|
||||
if(position != null){
|
||||
ClimateUtil.writePositionData(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -432,5 +438,10 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
breedingProgressPercent = data.readVarInt();
|
||||
tempChange = data.readVarInt() / 100.0F;
|
||||
humidChange = data.readVarInt() / 100.0F;
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getReferenceCoord());
|
||||
if(position != null){
|
||||
ClimateUtil.readPositionData(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
@@ -30,6 +31,7 @@ import forestry.core.owner.OwnerHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IClimatised;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.core.utils.ClimateUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
@@ -153,11 +155,19 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeVarInt(beeLogic.getBeeProgressPercent());
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getPos());
|
||||
if(position != null){
|
||||
ClimateUtil.writePositionData(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
breedingProgressPercent = data.readVarInt();
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getPos());
|
||||
if(position != null){
|
||||
ClimateUtil.readPositionData(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
// / IBEEHOUSING
|
||||
|
||||
@@ -53,7 +53,6 @@ import forestry.arboriculture.genetics.TreekeepingMode;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleFruit;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleGrowth;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleLeafEffect;
|
||||
import forestry.arboriculture.items.ItemCharcoal;
|
||||
import forestry.arboriculture.items.ItemGrafter;
|
||||
import forestry.arboriculture.items.ItemRegistryArboriculture;
|
||||
import forestry.arboriculture.models.TextureLeaves;
|
||||
@@ -540,10 +539,6 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
return 100;
|
||||
}
|
||||
|
||||
if(items.charcoal == item){
|
||||
return ItemCharcoal.getBurnTime(fuel);
|
||||
}
|
||||
|
||||
Block block = Block.getBlockFromItem(item);
|
||||
|
||||
if (block instanceof IWoodTyped) {
|
||||
|
||||
@@ -41,7 +41,6 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockDecorativeLeaves extends Block implements IItemModelRegister, IColoredBlock, IShearable {
|
||||
private static final int VARIANTS_PER_BLOCK = 16;
|
||||
private static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
public static List<BlockDecorativeLeaves> create() {
|
||||
List<BlockDecorativeLeaves> blocks = new ArrayList<>();
|
||||
@@ -148,7 +147,8 @@ public abstract class BlockDecorativeLeaves extends Block implements IItemModelR
|
||||
|
||||
@Nonnull
|
||||
public TreeDefinition getTreeType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + blockNumber * VARIANTS_PER_BLOCK;
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + blockNumber * VARIANTS_PER_BLOCK;
|
||||
return TreeDefinition.byMetadata(variantMeta);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -414,9 +415,17 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
|
||||
if (getPileType() == EnumPileType.ASH) {
|
||||
if (pile.getTreeSpecies() != null) {
|
||||
IWoodProvider woodProvider = pile.getTreeSpecies().getWoodProvider();
|
||||
ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, woodProvider.getCarbonization(), woodProvider.getCombustibility());
|
||||
int charcoalAmount = woodProvider.getCarbonization();
|
||||
ItemStack charcoal = new ItemStack(Items.COAL, charcoalAmount, 1);
|
||||
while(RANDOM.nextFloat() < woodProvider.getCharcoalChance(charcoalAmount)){
|
||||
charcoal.stackSize++;
|
||||
}
|
||||
list.add(charcoal);
|
||||
list.add(new ItemStack(PluginCore.items.ash, 3));
|
||||
int ashAmount = (int)(charcoalAmount / 1.5);
|
||||
if(ashAmount <= 0){
|
||||
ashAmount = 1;
|
||||
}
|
||||
list.add(new ItemStack(PluginCore.items.ash, ashAmount));
|
||||
} else {
|
||||
list.add(new ItemStack(Blocks.DIRT, 2));
|
||||
list.add(new ItemStack(PluginCore.items.ash, 2));
|
||||
|
||||
@@ -37,7 +37,7 @@ public enum BlockTypeArboricultureTesr implements IBlockTypeTesr {
|
||||
if (boundingBox != null) {
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
|
||||
} else {
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0");
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ public abstract class BlockArbFence extends BlockForestryFence<EnumForestryWoodT
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,8 @@ public abstract class BlockFireproofVanillaFence extends BlockForestryFence<Enum
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,6 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends BlockFence implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 16;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
|
||||
@@ -42,7 +42,8 @@ public abstract class BlockArbLog extends BlockForestryLog<EnumForestryWoodType>
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,8 @@ public abstract class BlockFireproofVanillaLog extends BlockForestryLog<EnumVani
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockForestryLog<T extends Enum<T> & IWoodType> extends BlockLog implements IWoodTyped, IStateMapperRegister, IItemModelRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 4;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
|
||||
@@ -42,7 +42,8 @@ public abstract class BlockArbPlanks extends BlockForestryPlanks<EnumForestryWoo
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,8 @@ public abstract class BlockFireproofVanillaPlanks extends BlockForestryPlanks<En
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockForestryPlanks<T extends Enum<T> & IWoodType> extends Block implements IWoodTyped, IStateMapperRegister, IItemModelRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 16;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
|
||||
@@ -50,7 +50,9 @@ public abstract class BlockArbSlab extends BlockForestrySlab<EnumForestryWoodTyp
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
meta &= ~8; // unset the top/bottom slab bit
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,9 @@ public abstract class BlockFireproofVanillaSlab extends BlockForestrySlab<EnumVa
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
meta &= ~8; // unset the top/bottom slab bit
|
||||
int variantCount = getVariant().getAllowedValues().size();
|
||||
int variantMeta = (meta % variantCount) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,6 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends BlockSlab implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 8;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
@@ -77,11 +76,13 @@ public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends B
|
||||
return blockNumber;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return this.isDouble() ? new BlockStateContainer(this, getVariant()) : new BlockStateContainer(this, HALF, getVariant());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
T woodType = getWoodType(meta);
|
||||
@@ -100,8 +101,7 @@ public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends B
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
T woodType = state.getValue(getVariant());
|
||||
int meta = woodType.getMetadata() - blockNumber * VARIANTS_PER_BLOCK;
|
||||
int meta = damageDropped(state);
|
||||
|
||||
if (!this.isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP) {
|
||||
meta |= 8;
|
||||
@@ -112,7 +112,8 @@ public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends B
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return state.getValue(getVariant()).getMetadata() - blockNumber * VARIANTS_PER_BLOCK;
|
||||
T woodType = state.getValue(getVariant());
|
||||
return woodType.getMetadata() - blockNumber * VARIANTS_PER_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -273,12 +273,11 @@ public class Tree extends Individual implements ITree, IPlantable {
|
||||
String girth = TextFormatting.AQUA + "G: " + String.format("%sx%s", genome.getGirth(), genome.getGirth());
|
||||
String saplings = TextFormatting.YELLOW + "S: " + genome.getActiveAllele(EnumTreeChromosome.FERTILITY).getName();
|
||||
String yield = TextFormatting.WHITE + "Y: " + genome.getActiveAllele(EnumTreeChromosome.YIELD).getName();
|
||||
String combustibility = TextFormatting.DARK_GRAY + "CO: " + primary.getWoodProvider().getCombustibility();
|
||||
String carbonization = TextFormatting.GRAY + "CA: " + secondary.getWoodProvider().getCarbonization();
|
||||
list.add(String.format("%s, %s", saplings, maturation));
|
||||
list.add(String.format("%s, %s", height, girth));
|
||||
list.add(String.format("%s, %s", yield, sappiness));
|
||||
list.add(String.format("%s, %s", combustibility, carbonization));
|
||||
list.add(String.format("%s", carbonization));
|
||||
|
||||
IAlleleBoolean primaryFireproof = (IAlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF);
|
||||
if (primaryFireproof.getValue()) {
|
||||
|
||||
@@ -138,14 +138,6 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin {
|
||||
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);
|
||||
|
||||
@@ -60,14 +60,14 @@ public class WoodProvider implements IWoodProvider {
|
||||
return TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCombustibility() {
|
||||
return woodType.getCombustability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCarbonization() {
|
||||
return woodType.getCarbonization();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCharcoalChance(int numberOfCharcoal){
|
||||
return woodType.getCharcoalChance(numberOfCharcoal);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,10 +79,10 @@ public class WoodProviderVanilla implements IWoodProvider {
|
||||
public ItemStack getWoodStack() {
|
||||
return TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCombustibility() {
|
||||
return woodType.getCombustability();
|
||||
public float getCharcoalChance(int numberOfCharcoal){
|
||||
return woodType.getCharcoalChance(numberOfCharcoal);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package forestry.arboriculture.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.items.ItemForestry;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemCharcoal extends ItemForestry {
|
||||
|
||||
public ItemCharcoal() {
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> subItems) {
|
||||
for(int i = 1;i < 25;i++){
|
||||
subItems.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for(int i = 1;i < 25;i++){
|
||||
manager.registerItemModel(item, i);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getBurnTime(ItemStack fuel) {
|
||||
return fuel.getMetadata() * 100;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.items;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
@@ -21,7 +19,6 @@ import forestry.core.utils.OreDictUtil;
|
||||
public class ItemRegistryArboriculture extends ItemRegistry {
|
||||
public final ItemGermlingGE sapling;
|
||||
public final ItemGermlingGE pollenFertile;
|
||||
public final ItemCharcoal charcoal;
|
||||
public final ItemGrafter grafter;
|
||||
public final ItemGrafter grafterProven;
|
||||
|
||||
@@ -31,10 +28,6 @@ public class ItemRegistryArboriculture extends ItemRegistry {
|
||||
|
||||
pollenFertile = registerItem(new ItemGermlingGE(EnumGermlingType.POLLEN), "pollenFertile");
|
||||
|
||||
charcoal = registerItem(new ItemCharcoal(), "charcoal");
|
||||
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(charcoal, 1, OreDictionary.WILDCARD_VALUE));
|
||||
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(Items.COAL, 1, 1));
|
||||
|
||||
grafter = registerItem(new ItemGrafter(9), "grafter");
|
||||
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
|
||||
}
|
||||
|
||||
@@ -11,25 +11,7 @@
|
||||
package forestry.arboriculture.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.ILeafSpriteProvider;
|
||||
@@ -37,80 +19,44 @@ import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.arboriculture.blocks.BlockDecorativeLeaves;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.core.models.ModelBlockDefault;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import forestry.core.models.baker.ModelBaker;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class ModelDecorativeLeaves extends ModelBlockDefault<BlockDecorativeLeaves> {
|
||||
|
||||
public class ModelDecorativeLeaves extends ModelBlockCached<BlockDecorativeLeaves, TreeDefinition> {
|
||||
public ModelDecorativeLeaves() {
|
||||
super(BlockDecorativeLeaves.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
IModelBaker baker = new ModelBaker();
|
||||
|
||||
Block block = state.getBlock();
|
||||
if (!blockClass.isInstance(block)) {
|
||||
@Override
|
||||
protected TreeDefinition getInventoryKey(@Nonnull ItemStack stack) {
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (!(block instanceof BlockDecorativeLeaves)) {
|
||||
return null;
|
||||
}
|
||||
BlockDecorativeLeaves bBlock = blockClass.cast(block);
|
||||
TreeDefinition tree = state.getValue(bBlock.getVariant());
|
||||
|
||||
baker.setRenderBounds(Block.FULL_BLOCK_AABB);
|
||||
bakeBlock(bBlock, tree, baker);
|
||||
|
||||
blockModel = baker.bakeModel(false);
|
||||
return blockModel.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemOverrideList createOverrides() {
|
||||
return new LeaveOverideList(this);
|
||||
}
|
||||
|
||||
private static class LeaveOverideList extends ItemOverrideList{
|
||||
|
||||
private final ModelDecorativeLeaves modelDecorativeLeaves;
|
||||
|
||||
public LeaveOverideList(ModelDecorativeLeaves modelDecorativeLeaves) {
|
||||
super(Collections.emptyList());
|
||||
this.modelDecorativeLeaves = modelDecorativeLeaves;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
IModelBaker baker = new ModelBaker();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (!modelDecorativeLeaves.blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
BlockDecorativeLeaves bBlock = modelDecorativeLeaves.blockClass.cast(block);
|
||||
TreeDefinition tree = bBlock.getTreeType(stack.getMetadata());
|
||||
|
||||
baker.setRenderBounds(Block.FULL_BLOCK_AABB);
|
||||
bakeBlock(bBlock, tree, baker);
|
||||
|
||||
return modelDecorativeLeaves.itemModel = baker.bakeModel(true);
|
||||
}
|
||||
|
||||
BlockDecorativeLeaves bBlock = (BlockDecorativeLeaves) block;
|
||||
return bBlock.getTreeType(stack.getMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeInventoryBlock(@Nonnull BlockDecorativeLeaves block, @Nonnull ItemStack item, @Nonnull IModelBaker baker) {
|
||||
|
||||
protected TreeDefinition getWorldKey(@Nonnull IBlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (!(block instanceof BlockDecorativeLeaves)) {
|
||||
return null;
|
||||
}
|
||||
BlockDecorativeLeaves bBlock = (BlockDecorativeLeaves) block;
|
||||
return state.getValue(bBlock.getVariant());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeWorldBlock(@Nonnull BlockDecorativeLeaves block, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IExtendedBlockState stateExtended, @Nonnull IModelBaker baker) {
|
||||
}
|
||||
|
||||
public static void bakeBlock(BlockDecorativeLeaves block, TreeDefinition treeDefinition, IModelBaker baker) {
|
||||
if (treeDefinition == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected void bakeBlock(@Nonnull BlockDecorativeLeaves block, @Nonnull TreeDefinition treeDefinition, @Nonnull IModelBaker baker, boolean inventory) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
|
||||
ITreeGenome genome = treeDefinition.getGenome();
|
||||
@@ -119,7 +65,7 @@ public class ModelDecorativeLeaves extends ModelBlockDefault<BlockDecorativeLeav
|
||||
|
||||
ResourceLocation leafSpriteLocation = leafSpriteProvider.getSprite(false, Proxies.render.fancyGraphicsEnabled());
|
||||
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
|
||||
|
||||
|
||||
// Render the plain leaf block.
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leafSprite, 0);
|
||||
|
||||
@@ -129,8 +75,31 @@ public class ModelDecorativeLeaves extends ModelBlockDefault<BlockDecorativeLeav
|
||||
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitSprite, 1);
|
||||
}
|
||||
|
||||
|
||||
// Set the particle sprite
|
||||
baker.setParticleSprite(leafSprite);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected IBakedModel bakeModel(@Nonnull IBlockState state, @Nonnull TreeDefinition key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IModelBaker baker = new ModelBaker();
|
||||
|
||||
Block block = state.getBlock();
|
||||
if (!blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
BlockDecorativeLeaves bBlock = blockClass.cast(block);
|
||||
|
||||
baker.setRenderBounds(Block.FULL_BLOCK_AABB);
|
||||
bakeBlock(bBlock, key, baker, false);
|
||||
|
||||
blockModel = baker.bakeModel(false);
|
||||
onCreateModel(blockModel);
|
||||
return blockModel;
|
||||
}
|
||||
}
|
||||
@@ -11,40 +11,60 @@
|
||||
package forestry.arboriculture.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import java.util.Objects;
|
||||
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.arboriculture.blocks.BlockForestryLeaves;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.genetics.TreeRoot;
|
||||
import forestry.arboriculture.items.ItemBlockLeaves;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.models.ModelBlockDefault;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
|
||||
public class ModelLeaves extends ModelBlockCached<BlockForestryLeaves, ModelLeaves.Key> {
|
||||
public static class Key {
|
||||
public final TextureAtlasSprite leafSprite, fruitSprite;
|
||||
public final boolean fancy;
|
||||
private final int hashCode;
|
||||
|
||||
public ModelLeaves() {
|
||||
super(BlockForestryLeaves.class);
|
||||
public Key(TextureAtlasSprite leafSprite, TextureAtlasSprite fruitSprite, boolean fancy) {
|
||||
this.leafSprite = leafSprite;
|
||||
this.fruitSprite = fruitSprite;
|
||||
this.fancy = fancy;
|
||||
this.hashCode = Objects.hash(leafSprite, fruitSprite, fancy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null || !(other instanceof Key)) {
|
||||
return false;
|
||||
} else {
|
||||
Key otherKey = (Key) other;
|
||||
return otherKey.leafSprite == leafSprite && otherKey.fruitSprite == fruitSprite && otherKey.fancy == fancy;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bakeInventoryBlock(@Nonnull BlockForestryLeaves block, @Nonnull ItemStack itemStack, @Nonnull IModelBaker baker) {
|
||||
if (!(itemStack.getItem() instanceof ItemBlockLeaves) || block == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected Key getInventoryKey(@Nonnull ItemStack itemStack) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
|
||||
TileLeaves leaves = new TileLeaves();
|
||||
@@ -54,55 +74,55 @@ public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
|
||||
leaves.setTree(TreeRoot.treeTemplates.get(0));
|
||||
}
|
||||
|
||||
ResourceLocation leafSpriteLocation = leaves.getLeaveSprite(Proxies.render.fancyGraphicsEnabled());
|
||||
TextureAtlasSprite leavesIcon = map.getAtlasSprite(leafSpriteLocation.toString());
|
||||
if (leavesIcon == null) {
|
||||
return;
|
||||
}
|
||||
boolean fancy = Proxies.render.fancyGraphicsEnabled();
|
||||
ResourceLocation leafLocation = leaves.getLeaveSprite(fancy);
|
||||
ResourceLocation fruitLocation = leaves.getFruitSprite();
|
||||
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leavesIcon, 0);
|
||||
|
||||
// add fruit
|
||||
if (!leaves.hasFruit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceLocation fruitSpriteLocation = leaves.getFruitSprite();
|
||||
if (fruitSpriteLocation != null) {
|
||||
TextureAtlasSprite fruitTexture = map.getAtlasSprite(fruitSpriteLocation.toString());
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitTexture, 1);
|
||||
}
|
||||
return new Key(map.getAtlasSprite(leafLocation.toString()),
|
||||
fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null,
|
||||
fancy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bakeWorldBlock(@Nonnull BlockForestryLeaves block, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IExtendedBlockState stateExtended, @Nonnull IModelBaker baker) {
|
||||
protected Key getWorldKey(@Nonnull IBlockState state) {
|
||||
IExtendedBlockState stateExtended = (IExtendedBlockState) state;
|
||||
IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
|
||||
BlockPos pos = stateExtended.getValue(UnlistedBlockPos.POS);
|
||||
|
||||
TileLeaves tile = TileUtil.getTile(world, pos, TileLeaves.class);
|
||||
boolean fancy = Proxies.render.fancyGraphicsEnabled();
|
||||
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
|
||||
if (tile == null) {
|
||||
IAlleleTreeSpecies oakSpecies = TreeDefinition.Oak.getIndividual().getGenome().getPrimary();
|
||||
ResourceLocation spriteLocation = oakSpecies.getLeafSpriteProvider().getSprite(false, Proxies.render.fancyGraphicsEnabled());
|
||||
ResourceLocation spriteLocation = oakSpecies.getLeafSpriteProvider().getSprite(false, fancy);
|
||||
TextureAtlasSprite sprite = map.getAtlasSprite(spriteLocation.toString());
|
||||
baker.setParticleSprite(sprite);
|
||||
return;
|
||||
return new Key(sprite, null, fancy);
|
||||
}
|
||||
|
||||
ResourceLocation leafSpriteLocation = tile.getLeaveSprite(Proxies.render.fancyGraphicsEnabled());
|
||||
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
|
||||
|
||||
ResourceLocation leafLocation = tile.getLeaveSprite(fancy);
|
||||
ResourceLocation fruitLocation = tile.getFruitSprite();
|
||||
|
||||
return new Key(map.getAtlasSprite(leafLocation.toString()),
|
||||
fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null,
|
||||
fancy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeBlock(@Nonnull BlockForestryLeaves block, @Nonnull Key key, @Nonnull IModelBaker baker, boolean inventory) {
|
||||
// Render the plain leaf block.
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leafSprite, 0);
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, key.leafSprite, 0);
|
||||
|
||||
// Render overlay for fruit leaves.
|
||||
ResourceLocation fruitSpriteLocation = tile.getFruitSprite();
|
||||
|
||||
if (fruitSpriteLocation != null) {
|
||||
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitSprite, 1);
|
||||
if (key.fruitSprite != null) {
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, key.fruitSprite, 1);
|
||||
}
|
||||
|
||||
|
||||
// Set the particle sprite
|
||||
baker.setParticleSprite(leafSprite);
|
||||
baker.setParticleSprite(key.leafSprite);
|
||||
}
|
||||
|
||||
public ModelLeaves() {
|
||||
super(BlockForestryLeaves.class);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package forestry.arboriculture.models;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
@@ -31,6 +32,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.ModelProcessingHelper;
|
||||
@@ -38,14 +40,22 @@ import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelWoodPile extends BlankModel{
|
||||
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> textureGetter = new DefaultTextureGetter();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IModel modelWoodPileItem;
|
||||
private IModel modelWoodPileBlock;
|
||||
private static final Map<String, IBakedModel> blockCache = new HashMap<>();
|
||||
private static final Map<String, IBakedModel> itemCache = new HashMap<>();
|
||||
private static IModel modelWoodPileItem;
|
||||
private static IModel modelWoodPileBlock;
|
||||
private static final Cache<String, IBakedModel> blockCache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).build();
|
||||
private static final Cache<String, IBakedModel> itemCache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).build();
|
||||
|
||||
/**
|
||||
* Init the model with datas from the ModelBakeEvent.
|
||||
*/
|
||||
public static void onModelBake(ModelBakeEvent event){
|
||||
blockCache.invalidateAll();
|
||||
itemCache.invalidateAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
@@ -103,16 +113,19 @@ public class ModelWoodPile extends BlankModel{
|
||||
}
|
||||
|
||||
private IBakedModel bakeModel(IAlleleTreeSpecies treeSpecies, boolean isItem) {
|
||||
if(treeSpecies == null || treeSpecies.getWoodProvider() == null || treeSpecies.getWoodProvider().getSprite(false) == null){
|
||||
return null;
|
||||
}
|
||||
ImmutableMap.Builder<String, String> textures = ImmutableMap.builder();
|
||||
String treeUID = treeSpecies.getUID();
|
||||
Map<String, IBakedModel> map = isItem ? itemCache : blockCache;
|
||||
if(!map.containsKey(treeUID)){
|
||||
Cache<String, IBakedModel> map = isItem ? itemCache : blockCache;
|
||||
if(map.getIfPresent(treeUID) == null){
|
||||
textures.put("woodBark", treeSpecies.getWoodProvider().getSprite(false).getIconName());
|
||||
textures.put("woodTop", treeSpecies.getWoodProvider().getSprite(true).getIconName());
|
||||
IModel retextureWoodPile = ModelProcessingHelper.retexture(isItem ? modelWoodPileItem : modelWoodPileBlock, textures.build());
|
||||
map.put(treeUID, retextureWoodPile.bake(ModelRotation.X0_Y0, isItem ? DefaultVertexFormats.ITEM : DefaultVertexFormats.BLOCK, textureGetter));
|
||||
}
|
||||
return map.get(treeUID);
|
||||
return map.getIfPresent(treeUID);
|
||||
}
|
||||
|
||||
private class PileItemOverrideList extends ItemOverrideList {
|
||||
|
||||
@@ -111,18 +111,26 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
|
||||
if (!isActive()) {
|
||||
return false;
|
||||
}
|
||||
if(woodBurnTime == 0){
|
||||
int comps = 0;
|
||||
if(woodBurnTime == 0 && tickCount % 20 == 0){
|
||||
int validComps = 0;
|
||||
int newBurnTime = 0;
|
||||
for (IMultiblockComponent part : connectedParts) {
|
||||
ICharcoalPileComponent comp = (ICharcoalPileComponent) part;
|
||||
if (comp.getTreeSpecies() != null) {
|
||||
comps++;
|
||||
validComps++;
|
||||
IWoodProvider woodProvider = comp.getTreeSpecies().getWoodProvider();
|
||||
newBurnTime += woodProvider.getCombustibility() * 1000;
|
||||
int charcoalAmount = woodProvider.getCarbonization();
|
||||
while(worldObj.rand.nextFloat() < woodProvider.getCharcoalChance(charcoalAmount)){
|
||||
charcoalAmount++;
|
||||
}
|
||||
newBurnTime += charcoalAmount * 500;
|
||||
}
|
||||
}
|
||||
woodBurnTime = newBurnTime / comps;
|
||||
if(validComps <= 0){
|
||||
woodBurnTime = newBurnTime / validComps;
|
||||
}else{
|
||||
woodBurnTime = 0;
|
||||
}
|
||||
}
|
||||
if (burnTime >= woodBurnTime) {
|
||||
for(IMultiblockComponent part : connectedParts) {
|
||||
@@ -156,8 +164,12 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
|
||||
|
||||
@Override
|
||||
protected void isMachineWhole() throws MultiblockValidationException {
|
||||
int minX = getSizeLimits().getMinimumXSize();
|
||||
int minY = getSizeLimits().getMinimumYSize();
|
||||
int minZ = getSizeLimits().getMinimumZSize();
|
||||
|
||||
if (connectedParts.size() < getSizeLimits().getMinimumNumberOfBlocksForAssembledMachine()) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocal("multiblock.error.small"));
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small", minX, minY, minZ));
|
||||
}
|
||||
BlockPos maximumCoord = getMaximumCoord();
|
||||
BlockPos minimumCoord = getMinimumCoord();
|
||||
@@ -168,26 +180,23 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
|
||||
int maxX = getSizeLimits().getMaximumXSize();
|
||||
int maxY = getSizeLimits().getMaximumYSize();
|
||||
int maxZ = getSizeLimits().getMaximumZSize();
|
||||
int minX = getSizeLimits().getMinimumXSize();
|
||||
int minY = getSizeLimits().getMinimumYSize();
|
||||
int minZ = getSizeLimits().getMinimumZSize();
|
||||
if (maxX > 0 && deltaX > maxX) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("multiblock.error.large.x", maxX));
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.large.x", maxX));
|
||||
}
|
||||
if (maxY > 0 && deltaY > maxY) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("multiblock.error.large.y", maxY));
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.large.y", maxY));
|
||||
}
|
||||
if (maxZ > 0 && deltaZ > maxZ) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("multiblock.error.large.z", maxZ));
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.large.z", maxZ));
|
||||
}
|
||||
if (deltaX < minX) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("multiblock.error.small.x", minX));
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small.x", minX));
|
||||
}
|
||||
if (deltaY < minY) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("multiblock.error.small.y", minY));
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small.y", minY));
|
||||
}
|
||||
if (deltaZ < minZ) {
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("multiblock.error.small.z", minZ));
|
||||
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small.z", minZ));
|
||||
}
|
||||
|
||||
TileEntity te;
|
||||
|
||||
@@ -153,6 +153,7 @@ public class ProxyArboricultureClient extends ProxyArboriculture {
|
||||
}
|
||||
|
||||
loadingExceptions.putAll(WoodModelLoader.loadingExceptions);
|
||||
ModelWoodPile.onModelBake(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ public class WorldGenAcacia extends WorldGenTree {
|
||||
public WorldGenAcacia(ITreeGenData tree) {
|
||||
super(tree, 5, 2);
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
|
||||
@@ -41,20 +41,21 @@ public class WorldGenAcacia extends WorldGenTree {
|
||||
treeTops.addAll(treeTops2);
|
||||
}
|
||||
|
||||
Set<BlockPos> branchEnds = new HashSet<>(treeTops);
|
||||
Set<BlockPos> branchEnds = new HashSet<>();
|
||||
|
||||
for (BlockPos treeTop : treeTops) {
|
||||
int xOffset = treeTop.getX();
|
||||
int yOffset = treeTop.getY() + 1;
|
||||
int yOffset = treeTop.getY() - startPos.getY() + 1;
|
||||
int zOffset = treeTop.getZ();
|
||||
float canopyMultiplier = (1.5f * height - yOffset + 2) / 4.0f;
|
||||
int canopyThickness = Math.max(1, Math.round(yOffset / 10.0f));
|
||||
|
||||
|
||||
branchEnds.add(new BlockPos(xOffset, startPos.getY() + yOffset--, zOffset));
|
||||
yOffset--;
|
||||
|
||||
float canopyWidth = rand.nextBoolean() ? 3.0f : 2.5f;
|
||||
int radius = Math.round(canopyMultiplier * canopyWidth - 4);
|
||||
BlockPos pos = startPos.add(xOffset, yOffset - canopyThickness, zOffset);
|
||||
BlockPos pos = new BlockPos(xOffset, startPos.getY() + yOffset - canopyThickness, zOffset);
|
||||
branchEnds.addAll(WorldGenHelper.generateBranches(world, rand, wood, pos, girth, 0.0f, 0.1f, radius, 2, 1.0f));
|
||||
}
|
||||
|
||||
@@ -64,11 +65,11 @@ public class WorldGenAcacia extends WorldGenTree {
|
||||
@Override
|
||||
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
|
||||
for (BlockPos branchEnd : branchEnds) {
|
||||
int leafSpawn = branchEnd.getY();
|
||||
int leafSpawn = branchEnd.getY() - startPos.getY();
|
||||
int canopyThickness = Math.max(1, Math.round(leafSpawn / 10.0f));
|
||||
float canopyMultiplier = (1.5f * height - leafSpawn + 2) / 4.0f;
|
||||
float canopyWidth = rand.nextBoolean() ? 2.0f : 4.5f;
|
||||
BlockPos center = new BlockPos(branchEnd.getX(), leafSpawn - canopyThickness + 1, branchEnd.getZ());
|
||||
float canopyWidth = rand.nextBoolean() ? 1.0f : 1.5f;
|
||||
BlockPos center = new BlockPos(branchEnd.getX(), leafSpawn - canopyThickness + 1 + startPos.getY(), branchEnd.getZ());
|
||||
float radius = Math.max(1, canopyMultiplier * canopyWidth + girth);
|
||||
WorldGenHelper.generateCylinderFromPos(world, leaf, center, radius, canopyThickness, WorldGenHelper.EnumReplaceMode.AIR);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
|
||||
private static final Map<String, List<ICamouflageItemHandler>> camouflageItemHandlers = new HashMap<>();
|
||||
private static final Map<String, List<ItemStack>> camouflageItemBlacklist = new HashMap<>();
|
||||
private static final Map<String, List<String>> blacklistedMods = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerCamouflageItemHandler(@Nonnull ICamouflageItemHandler itemHandler) {
|
||||
@@ -60,6 +61,16 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
return camouflageItemHandlers.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModIdToBlackList(String type, String modID) {
|
||||
if(!blacklistedMods.containsKey(type)){
|
||||
blacklistedMods.put(type, new ArrayList<>());
|
||||
}
|
||||
if(!blacklistedMods.get(type).contains(modID)){
|
||||
blacklistedMods.get(type).add(modID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemToBlackList(String type, ItemStack camouflageBlock) {
|
||||
if (camouflageBlock == null || camouflageBlock.getItem() == null) {
|
||||
@@ -77,6 +88,9 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!camouflageItemBlacklist.containsKey(type)){
|
||||
camouflageItemBlacklist.put(type, new ArrayList<>());
|
||||
}
|
||||
camouflageItemBlacklist.get(type).add(camouflageBlock);
|
||||
}
|
||||
|
||||
@@ -85,6 +99,10 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
if (camouflageBlock == null || camouflageBlock.getItem() == null || Block.getBlockFromItem(camouflageBlock.getItem()) == null || type != null && !camouflageItemBlacklist.containsKey(type)) {
|
||||
return false;
|
||||
}
|
||||
String modId = camouflageBlock.getItem().getRegistryName().getResourceDomain();
|
||||
if(blacklistedMods.get(type) != null && blacklistedMods.get(type).contains(modId)){
|
||||
return true;
|
||||
}
|
||||
List<ItemStack> camouflageItemBlacklisted;
|
||||
if(type == null){
|
||||
camouflageItemBlacklisted = new ArrayList<>();
|
||||
@@ -99,6 +117,7 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import jline.internal.Log;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -68,6 +70,10 @@ public class CamouflageHandlerDoor implements ICamouflageItemHandler {
|
||||
ItemDoor itemDoor = (ItemDoor) stack.getItem();
|
||||
Block doorBlock = ObfuscationReflectionHelper.getPrivateValue(ItemDoor.class, itemDoor, 0);
|
||||
|
||||
if(doorBlock == null){
|
||||
Log.error("Can't render Door : block is null for" + stack);
|
||||
return null;
|
||||
}
|
||||
IBlockState doorState = doorBlock.getDefaultState()
|
||||
.withProperty(BlockDoor.FACING, currentState.getValue(BlockDoor.FACING))
|
||||
.withProperty(BlockDoor.HINGE, currentState.getValue(BlockDoor.HINGE))
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.LootPool;
|
||||
@@ -94,6 +95,7 @@ public class EventHandlerCore {
|
||||
public void handleTextureRemap(TextureStitchEvent.Pre event) {
|
||||
ErrorStateRegistry.initSprites();
|
||||
TextureManager.initDefaultSprites();
|
||||
ModelBlockCached.clear();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -36,7 +36,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
@@ -140,6 +139,7 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
|
||||
return definition.collisionRayTrace(worldIn, pos, start, end);
|
||||
}
|
||||
|
||||
|
||||
/* TILE ENTITY CREATION */
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
@@ -231,6 +231,12 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new MachineStateMapper<>(blockType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state){
|
||||
IMachineProperties definition = getDefinition();
|
||||
return definition.isFullCube(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
|
||||
@@ -46,6 +46,8 @@ public interface IMachineProperties<T extends TileForestry> extends IStringSeria
|
||||
void setBlock(@Nonnull Block block);
|
||||
|
||||
Block getBlock();
|
||||
|
||||
boolean isFullCube(IBlockState state);
|
||||
|
||||
@Nonnull
|
||||
AxisAlignedBB getBoundingBox(@Nonnull BlockPos pos, @Nonnull IBlockState state);
|
||||
|
||||
@@ -108,4 +108,9 @@ public class MachineProperties<T extends TileForestry> implements IMachineProper
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package forestry.core.blocks;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -19,17 +20,28 @@ public class MachinePropertiesTesr<T extends TileForestry> extends MachineProper
|
||||
private final TileEntitySpecialRenderer<? super T> renderer;
|
||||
@Nonnull
|
||||
private final String particleTextureLocation;
|
||||
private final boolean isFullCube;
|
||||
|
||||
public MachinePropertiesTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nonnull String particleTextureLocation) {
|
||||
super(teClass, name);
|
||||
this.renderer = renderer;
|
||||
this.particleTextureLocation = particleTextureLocation;
|
||||
this(teClass, name, renderer, particleTextureLocation, true);
|
||||
}
|
||||
|
||||
public MachinePropertiesTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nonnull AxisAlignedBB boundingBox, @Nonnull String particleTextureLocation) {
|
||||
this(teClass, name, renderer, boundingBox, particleTextureLocation, true);
|
||||
}
|
||||
|
||||
public MachinePropertiesTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nonnull String particleTextureLocation, boolean isFullCube) {
|
||||
super(teClass, name);
|
||||
this.renderer = renderer;
|
||||
this.particleTextureLocation = particleTextureLocation;
|
||||
this.isFullCube = isFullCube;
|
||||
}
|
||||
|
||||
public MachinePropertiesTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nonnull AxisAlignedBB boundingBox, @Nonnull String particleTextureLocation, boolean isFullCube) {
|
||||
super(teClass, name, boundingBox);
|
||||
this.renderer = renderer;
|
||||
this.particleTextureLocation = particleTextureLocation;
|
||||
this.isFullCube = isFullCube;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -55,4 +67,9 @@ public class MachinePropertiesTesr<T extends TileForestry> extends MachineProper
|
||||
public String getParticleTextureLocation() {
|
||||
return particleTextureLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return isFullCube;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class CircuitBoard<T> implements ICircuitBoard {
|
||||
@Nonnull
|
||||
private final ICircuit[] circuits;
|
||||
|
||||
public CircuitBoard(@Nonnull EnumCircuitBoardType type, @Nonnull ICircuitLayout layout, @Nonnull ICircuit[] circuits) {
|
||||
public CircuitBoard(@Nonnull EnumCircuitBoardType type, @Nullable ICircuitLayout layout, @Nonnull ICircuit[] circuits) {
|
||||
this.type = type;
|
||||
this.layout = layout;
|
||||
this.circuits = circuits;
|
||||
|
||||
@@ -10,31 +10,33 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.circuits;
|
||||
|
||||
import forestry.core.render.ColourProperties;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public enum EnumCircuitBoardType {
|
||||
BASIC(1, 0x191919, 0x6dcff6),
|
||||
ENHANCED(2, 0x191919, 0xcb7c32),
|
||||
REFINED(3, 0x191919, 0xc9c9c9),
|
||||
INTRICATE(4, 0x191919, 0xe2cb6b);
|
||||
BASIC(1),
|
||||
ENHANCED(2),
|
||||
REFINED(3),
|
||||
INTRICATE(4);
|
||||
|
||||
private final int sockets;
|
||||
private final int primaryColor;
|
||||
private final int secondaryColor;
|
||||
|
||||
EnumCircuitBoardType(int sockets, int primaryColor, int secondaryColor) {
|
||||
EnumCircuitBoardType(int sockets) {
|
||||
this.sockets = sockets;
|
||||
this.primaryColor = primaryColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
}
|
||||
|
||||
public int getSockets() {
|
||||
return sockets;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getPrimaryColor() {
|
||||
return primaryColor;
|
||||
return ColourProperties.INSTANCE.get("item.circuit." + name().toLowerCase() + ".primary");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSecondaryColor() {
|
||||
return secondaryColor;
|
||||
return ColourProperties.INSTANCE.get("item.circuit." + name().toLowerCase() + ".secondary");
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import forestry.api.farming.FarmDirection;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.inventory.ItemInventorySolderingIron;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemInventorySolderingIron> {
|
||||
@@ -41,7 +42,7 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
|
||||
|
||||
ICircuitLayout layout = ((ContainerSolderingIron) inventorySlots).getLayout();
|
||||
String title = layout.getName();
|
||||
fontRendererObj.drawString(title, guiLeft + 8 + textLayout.getCenteredOffset(title, 138), guiTop + 16, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(title, guiLeft + 8 + textLayout.getCenteredOffset(title, 138), guiTop + 16, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
String description;
|
||||
@@ -54,7 +55,7 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
|
||||
}
|
||||
|
||||
int row = i * 20;
|
||||
fontRendererObj.drawString(description, guiLeft + 32, guiTop + 36 + row, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(description, guiLeft + 32, guiTop + 36 + row, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
|
||||
if (tube == null) {
|
||||
ICircuitSocketType socketType = layout.getSocketType();
|
||||
@@ -62,7 +63,7 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
|
||||
FarmDirection farmDirection = FarmDirection.values()[i];
|
||||
String farmDirectionString = farmDirection.toString().toLowerCase(Locale.ENGLISH);
|
||||
String localizedDirection = Translator.translateToLocal("for.gui.solder." + farmDirectionString);
|
||||
fontRendererObj.drawString(localizedDirection, guiLeft + 17, guiTop + 36 + row, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(localizedDirection, guiLeft + 17, guiTop + 36 + row, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateProvider;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.climate.IClimateSourceProvider;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.DefaultClimateProvider;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
@@ -115,36 +115,43 @@ public class ClimateManager implements IClimateManager{
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, pos);
|
||||
|
||||
if(position != null){
|
||||
return position.getTemperature();
|
||||
}
|
||||
if(position != null){
|
||||
return position.getTemperature();
|
||||
}
|
||||
return biome.getTemperature();
|
||||
return world.getBiome(pos).getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, pos);
|
||||
|
||||
if(position != null){
|
||||
return position.getHumidity();
|
||||
}
|
||||
if(position != null){
|
||||
return position.getHumidity();
|
||||
}
|
||||
return biome.getRainfall();
|
||||
return world.getBiome(pos).getRainfall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<IClimateRegion>> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimatePosition getPosition(World world, BlockPos pos){
|
||||
Integer dimensionID = Integer.valueOf(world.provider.getDimension());
|
||||
if(!regions.containsKey(dimensionID)){
|
||||
regions.put(dimensionID, new ArrayList<>());
|
||||
return null;
|
||||
}
|
||||
for(IClimateRegion region : regions.get(dimensionID)){
|
||||
if(region.getPositions().keySet().contains(pos)){
|
||||
return region.getPositions().get(pos);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegionForPos(World world, BlockPos pos){
|
||||
|
||||
@@ -25,6 +25,7 @@ import forestry.api.climate.IClimateSource;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.utils.ClimateUtil;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -245,7 +246,7 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
return positions;
|
||||
}
|
||||
|
||||
protected void addPosition(BlockPos pos, float temperature, float humidity){
|
||||
public void addPosition(BlockPos pos, float temperature, float humidity){
|
||||
IClimatePosition otherPosition = positions.get(pos);
|
||||
if(otherPosition != null){
|
||||
otherPosition.setHumidity(humidity);
|
||||
@@ -284,11 +285,7 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
if(!positions.isEmpty()){
|
||||
data.writeInt(positions.size());
|
||||
for(IClimatePosition pos : positions.values()){
|
||||
data.writeInt(pos.getPos().getX());
|
||||
data.writeInt(pos.getPos().getY());
|
||||
data.writeInt(pos.getPos().getZ());
|
||||
data.writeFloat(pos.getTemperature());
|
||||
data.writeFloat(pos.getHumidity());
|
||||
ClimateUtil.writeRoomPositionData(pos, data);
|
||||
}
|
||||
data.writeFloat(temperature);
|
||||
data.writeFloat(humidity);
|
||||
@@ -303,7 +300,7 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
if(size != 0){
|
||||
positions.clear();;
|
||||
for(int index = 0;index < size;index++){
|
||||
addPosition(new BlockPos(data.readInt(), data.readInt(), data.readInt()), data.readFloat(), data.readFloat());
|
||||
ClimateUtil.readRoomPositionData(this, data);
|
||||
}
|
||||
temperature = data.readFloat();
|
||||
humidity = data.readFloat();
|
||||
|
||||
@@ -62,7 +62,7 @@ public enum Fluids {
|
||||
return new BlockForestryFluid(this, 0, true);
|
||||
}
|
||||
},
|
||||
FOR_HONEY(new Color(255, 196, 35), 1420, 73600) {
|
||||
FOR_HONEY(new Color(255, 196, 35), 1420, 75600) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
@@ -73,7 +73,7 @@ public enum Fluids {
|
||||
return new DrinkProperties(2, 0.2f, 64);
|
||||
}
|
||||
},
|
||||
ICE(new Color(175, 242, 255), 920, 1000) {
|
||||
ICE(new Color(175, 242, 255), 520, 1000) {
|
||||
@Override
|
||||
public int getTemperature() {
|
||||
return 265;
|
||||
@@ -118,7 +118,7 @@ public enum Fluids {
|
||||
SHORT_MEAD(new Color(239, 154, 56), 1000, 1200) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
return new BlockForestryFluid(this, 4, true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -221,7 +221,7 @@ public enum Fluids {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Fluids getFluidDefinition(FluidStack fluidStack) {
|
||||
public static Fluids getFluidDefinition(@Nullable FluidStack fluidStack) {
|
||||
if (fluidStack != null) {
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid != null) {
|
||||
|
||||
@@ -43,6 +43,7 @@ import forestry.core.gui.widgets.ItemStackWidget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.inventory.ItemInventoryAlyzer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
@@ -60,9 +61,9 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
|
||||
public final int getColorCoding(boolean dominant) {
|
||||
if (dominant) {
|
||||
return fontColor.get("gui.beealyzer.dominant");
|
||||
return ColourProperties.INSTANCE.get("gui.beealyzer.dominant");
|
||||
} else {
|
||||
return fontColor.get("gui.beealyzer.recessive");
|
||||
return ColourProperties.INSTANCE.get("gui.beealyzer.recessive");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
}
|
||||
|
||||
public final void drawRow(String text0, String text1, String text2, IIndividual individual, IChromosomeType chromosome) {
|
||||
textLayout.drawRow(text0, text1, text2, fontColor.get("gui.screen"), getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant()),
|
||||
textLayout.drawRow(text0, text1, text2, ColourProperties.INSTANCE.get("gui.screen"), getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant()),
|
||||
getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant()));
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
IAllele active = individual.getGenome().getActiveAllele(chromosome);
|
||||
IAllele inactive = individual.getGenome().getInactiveAllele(chromosome);
|
||||
textLayout.drawRow(chromosomeName, active.getName(), inactive.getName(),
|
||||
fontColor.get("gui.screen"), getColorCoding(active.isDominant()),
|
||||
ColourProperties.INSTANCE.get("gui.screen"), getColorCoding(active.isDominant()),
|
||||
getColorCoding(inactive.isDominant()));
|
||||
}
|
||||
|
||||
@@ -195,10 +196,10 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
|
||||
textLayout.newLine();
|
||||
String title = Translator.translateToLocal("for.gui.portablealyzer").toUpperCase();
|
||||
textLayout.drawCenteredLine(title, 8, 208, fontColor.get("gui.screen"));
|
||||
textLayout.drawCenteredLine(title, 8, 208, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
textLayout.newLine();
|
||||
|
||||
fontRendererObj.drawSplitString(Translator.translateToLocal("for.gui.portablealyzer.help"), guiLeft + COLUMN_0 + 4, guiTop + 42, 200, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawSplitString(Translator.translateToLocal("for.gui.portablealyzer.help"), guiLeft + COLUMN_0 + 4, guiTop + 42, 200, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
@@ -265,7 +266,7 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(individual.getIdent())) {
|
||||
String extinct = ">> " + Translator.translateToLocal("for.gui.alyzer.extinct").toUpperCase() + " <<";
|
||||
fontRendererObj.drawStringWithShadow(extinct, guiLeft + 200 - fontRendererObj.getStringWidth(extinct),
|
||||
guiTop + textLayout.getLineY(), fontColor.get("gui.beealyzer.dominant"));
|
||||
guiTop + textLayout.getLineY(), ColourProperties.INSTANCE.get("gui.beealyzer.dominant"));
|
||||
}
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
@@ -3,6 +3,7 @@ package forestry.core.gui;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.widgets.WidgetCamouflageSlot;
|
||||
import forestry.core.inventory.ItemInventoryCamouflageSprayCan;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class GuiCamouflageSprayCan extends GuiForestry<ContainerCamouflageSprayC
|
||||
|
||||
String name = Translator.translateToLocal("for.gui.camouflage.spray.can");
|
||||
textLayout.line = 6;
|
||||
textLayout.drawCenteredLine(name, 0, fontColor.get("gui.title"));
|
||||
textLayout.drawCenteredLine(name, 0, ColourProperties.INSTANCE.get("gui.title"));
|
||||
bindTexture(textureFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.gui.widgets.GameTokenWidget;
|
||||
import forestry.core.gui.widgets.ProbeButton;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.tiles.EscritoireGame;
|
||||
import forestry.core.tiles.EscritoireTextSource;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
@@ -94,10 +95,10 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
|
||||
String format = TextFormatting.UNDERLINE + TextFormatting.ITALIC.toString();
|
||||
int attemptNo = EscritoireGame.BOUNTY_MAX - inventory.getGame().getBountyLevel();
|
||||
String attemptNoString = Translator.translateToLocalFormatted("for.gui.escritoire.attempt.number", attemptNo);
|
||||
textLayout.drawLine(format + attemptNoString, 170, fontColor.get("gui.mail.lettertext"));
|
||||
textLayout.drawLine(format + attemptNoString, 170, ColourProperties.INSTANCE.get("gui.mail.lettertext"));
|
||||
textLayout.newLine();
|
||||
String escritoireText = textSource.getText(inventory.getGame());
|
||||
textLayout.drawSplitLine(escritoireText, 170, 90, fontColor.get("gui.mail.lettertext"));
|
||||
textLayout.drawSplitLine(escritoireText, 170, 90, ColourProperties.INSTANCE.get("gui.mail.lettertext"));
|
||||
}
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import forestry.core.gui.ledgers.PowerLedger;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.FontColour;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.render.ForestryResource;
|
||||
import forestry.core.tiles.IClimatised;
|
||||
import forestry.core.tiles.IPowerHandler;
|
||||
@@ -49,7 +49,6 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
protected final WidgetManager widgetManager;
|
||||
protected LedgerManager ledgerManager;
|
||||
protected TextLayoutHelper textLayout;
|
||||
protected FontColour fontColor;
|
||||
|
||||
protected GuiForestry(String texture, C container, I inventory) {
|
||||
this(new ForestryResource(texture), container, inventory);
|
||||
@@ -65,8 +64,7 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
this.inventory = inventory;
|
||||
this.container = container;
|
||||
|
||||
this.fontColor = new FontColour(Proxies.render.getSelectedTexturePack());
|
||||
this.textLayout = new TextLayoutHelper(this, this.fontColor);
|
||||
this.textLayout = new TextLayoutHelper(this, ColourProperties.INSTANCE);
|
||||
}
|
||||
|
||||
/* LEDGERS */
|
||||
@@ -122,8 +120,8 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
ledgerManager.onGuiClosed();
|
||||
}
|
||||
|
||||
public FontColour getFontColor() {
|
||||
return fontColor;
|
||||
public ColourProperties getFontColor() {
|
||||
return ColourProperties.INSTANCE;
|
||||
}
|
||||
|
||||
public FontRenderer getFontRenderer() {
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.core.gui;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.tiles.ITitled;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
@@ -28,7 +28,7 @@ public abstract class GuiForestryTitled<C extends Container, I extends ITitled &
|
||||
|
||||
String name = Translator.translateToLocal(inventory.getUnlocalizedTitle());
|
||||
textLayout.line = 6;
|
||||
textLayout.drawCenteredLine(name, 0, fontColor.get("gui.title"));
|
||||
textLayout.drawCenteredLine(name, 0, ColourProperties.INSTANCE.get("gui.title"));
|
||||
bindTexture(textureFile);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import forestry.core.gui.buttons.GuiBetterButton;
|
||||
import forestry.core.gui.buttons.StandardButtonTextureSets;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInventory> {
|
||||
@@ -65,7 +66,7 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
super.drawGuiContainerBackgroundLayer(f, i, j);
|
||||
String header = Translator.translateToLocal("for.gui.page") + " " + (pageCurrent + 1) + "/" + pageMax;
|
||||
fontRendererObj.drawString(header, guiLeft + 95 + textLayout.getCenteredOffset(header, 98), guiTop + 10, fontColor.get("gui.title"));
|
||||
fontRendererObj.drawString(header, guiLeft + 95 + textLayout.getCenteredOffset(header, 98), guiTop + 10, ColourProperties.INSTANCE.get("gui.title"));
|
||||
|
||||
IIndividual individual = getIndividualAtPosition(i, j);
|
||||
if (individual == null) {
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.core.gui;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import forestry.core.render.FontColour;
|
||||
import forestry.core.render.ColourProperties;
|
||||
|
||||
public class TextLayoutHelper {
|
||||
private static final int LINE_HEIGHT = 12;
|
||||
@@ -25,7 +25,7 @@ public class TextLayoutHelper {
|
||||
public int column2;
|
||||
public int line;
|
||||
|
||||
public TextLayoutHelper(GuiForestry guiForestry, FontColour fontColour) {
|
||||
public TextLayoutHelper(GuiForestry guiForestry, ColourProperties fontColour) {
|
||||
this.guiForestry = guiForestry;
|
||||
this.defaultFontColor = fontColour.get("gui.screen");
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class WidgetCamouflageSlot extends Widget {
|
||||
return;
|
||||
}
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
camouflageHandler.setCamouflageBlock(type, camouflageHandler.getDefaultCamouflageBlock(type));
|
||||
camouflageHandler.setCamouflageBlock(type, camouflageHandler.getDefaultCamouflageBlock(type), true);
|
||||
} else {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
@@ -64,7 +64,7 @@ public class WidgetCamouflageSlot extends Widget {
|
||||
if (!CamouflageManager.camouflageAccess.isItemBlackListed(type, stack)) {
|
||||
for(ICamouflageItemHandler handler : CamouflageManager.camouflageAccess.getCamouflageItemHandler(type)){
|
||||
if(handler != null && handler.canHandle(stack)){
|
||||
camouflageHandler.setCamouflageBlock(handler.getType(), stack.copy());
|
||||
camouflageHandler.setCamouflageBlock(handler.getType(), stack.copy(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,15 +32,17 @@ public class ItemInventoryCamouflageSprayCan extends ItemInventory implements IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
public boolean setCamouflageBlock(String type, ItemStack camouflageBlock, boolean sendClientUpdate) {
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, getStackInSlot(0))){
|
||||
setInventorySlotContents(0, camouflageBlock);
|
||||
|
||||
World world = player.worldObj;
|
||||
if (world != null && world.isRemote) {
|
||||
if (sendClientUpdate && world != null && world.isRemote) {
|
||||
Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.ITEM));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ItemCamouflageSprayCan extends ItemWithGui {
|
||||
String type = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflage).getType();
|
||||
if(type != null && handler.canHandleType(type)){
|
||||
if(world.isRemote){
|
||||
handler.setCamouflageBlock(type, camouflage);
|
||||
handler.setCamouflageBlock(type, camouflage, false);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package forestry.core.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class ModelBlockCached<B extends Block, K> extends ModelBlockDefault<B, K> {
|
||||
private static final Set<ModelBlockCached> CACHE_PROVIDERS = new HashSet<>();
|
||||
|
||||
private final Cache<K, IBakedModel> inventoryCache;
|
||||
private final Cache<K, IBakedModel> worldCache;
|
||||
|
||||
public static void clear() {
|
||||
for (ModelBlockCached modelBlockCached : CACHE_PROVIDERS) {
|
||||
modelBlockCached.worldCache.invalidateAll();
|
||||
modelBlockCached.inventoryCache.invalidateAll();
|
||||
}
|
||||
}
|
||||
|
||||
protected ModelBlockCached(@Nonnull Class<B> blockClass) {
|
||||
super(blockClass);
|
||||
|
||||
worldCache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).build();
|
||||
inventoryCache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).build();
|
||||
|
||||
CACHE_PROVIDERS.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBakedModel getModel(@Nonnull IBlockState state) {
|
||||
K key = getWorldKey(state);
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IBakedModel model = worldCache.getIfPresent(key);
|
||||
if (model == null) {
|
||||
model = bakeModel(state, key);
|
||||
if (model != null) {
|
||||
worldCache.put(key, model);
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBakedModel getModel(ItemStack stack, World world) {
|
||||
K key = getInventoryKey(stack);
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IBakedModel model = inventoryCache.getIfPresent(key);
|
||||
if (model == null) {
|
||||
model = bakeModel(stack, world, key);
|
||||
inventoryCache.put(key, model);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,18 @@
|
||||
package forestry.core.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.api.core.IModelBakerModel;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.baker.ModelBaker;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
@@ -27,16 +34,9 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.api.core.IModelBakerModel;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.baker.ModelBaker;
|
||||
|
||||
public abstract class ModelBlockDefault<B extends Block> implements IBakedModel {
|
||||
public abstract class ModelBlockDefault<B extends Block, K> implements IBakedModel {
|
||||
private ItemOverrideList overrideList;
|
||||
@Nonnull
|
||||
protected final Class<B> blockClass;
|
||||
@@ -48,28 +48,72 @@ public abstract class ModelBlockDefault<B extends Block> implements IBakedModel
|
||||
this.blockClass = blockClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
if(state instanceof IExtendedBlockState){
|
||||
IModelBaker baker = new ModelBaker();
|
||||
@Nullable
|
||||
protected IBakedModel bakeModel(@Nonnull IBlockState state, @Nonnull K key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IModelBaker baker = new ModelBaker();
|
||||
|
||||
Block block = state.getBlock();
|
||||
if (!blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
B bBlock = blockClass.cast(block);
|
||||
|
||||
if (state instanceof IExtendedBlockState) {
|
||||
IExtendedBlockState stateExtended = (IExtendedBlockState) state;
|
||||
|
||||
IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
|
||||
BlockPos pos = stateExtended.getValue(UnlistedBlockPos.POS);
|
||||
Block block = state.getBlock();
|
||||
if (!blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
B bBlock = blockClass.cast(block);
|
||||
|
||||
baker.setRenderBounds(block.getBoundingBox(state, world, pos));
|
||||
bakeWorldBlock(bBlock, world, pos, stateExtended, baker);
|
||||
|
||||
blockModel = baker.bakeModel(false);
|
||||
onCreateModel(blockModel);
|
||||
return blockModel.getQuads(state, side, rand);
|
||||
baker.setRenderBounds(state.getBoundingBox(world, pos));
|
||||
}
|
||||
|
||||
bakeBlock(bBlock, key, baker, false);
|
||||
|
||||
blockModel = baker.bakeModel(false);
|
||||
onCreateModel(blockModel);
|
||||
return blockModel;
|
||||
}
|
||||
|
||||
protected IBakedModel getModel(IBlockState state) {
|
||||
return bakeModel(state, getWorldKey(state));
|
||||
}
|
||||
|
||||
protected IBakedModel bakeModel(ItemStack stack, World world, K key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IModelBaker baker = new ModelBaker();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (!blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
B bBlock = blockClass.cast(block);
|
||||
|
||||
// FIXME: This way of getting the IBlockState will probably backfire.
|
||||
IBlockState state = block.getStateFromMeta(stack.getItemDamage());
|
||||
baker.setRenderBounds(state.getBoundingBox(world, null));
|
||||
bakeBlock(bBlock, key, baker, true);
|
||||
|
||||
return itemModel = baker.bakeModel(true);
|
||||
}
|
||||
|
||||
protected IBakedModel getModel(ItemStack stack, World world) {
|
||||
return bakeModel(stack, world, getInventoryKey(stack));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
IBakedModel model = getModel(state);
|
||||
|
||||
if (model != null) {
|
||||
return model.getQuads(state, side, rand);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected void onCreateModel(IModelBakerModel model){
|
||||
@@ -100,18 +144,20 @@ public abstract class ModelBlockDefault<B extends Block> implements IBakedModel
|
||||
return blockModel != null ? blockModel.isBuiltInRenderer() : itemModel.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
if(blockModel != null) {
|
||||
return blockModel.getParticleTexture();
|
||||
}
|
||||
return null;
|
||||
return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
if(itemModel == null) {
|
||||
return null;
|
||||
if (itemModel == null) {
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
return itemModel.getItemCameraTransforms();
|
||||
}
|
||||
@@ -120,6 +166,7 @@ public abstract class ModelBlockDefault<B extends Block> implements IBakedModel
|
||||
return new DefaultItemOverrideList();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
if (overrideList == null) {
|
||||
@@ -128,9 +175,10 @@ public abstract class ModelBlockDefault<B extends Block> implements IBakedModel
|
||||
return overrideList;
|
||||
}
|
||||
|
||||
protected abstract void bakeInventoryBlock(@Nonnull B block, @Nonnull ItemStack item, @Nonnull IModelBaker baker);
|
||||
protected abstract K getInventoryKey(@Nonnull ItemStack stack);
|
||||
|
||||
protected abstract void bakeWorldBlock(@Nonnull B block, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IExtendedBlockState stateExtended, @Nonnull IModelBaker baker);
|
||||
protected abstract K getWorldKey(@Nonnull IBlockState state);
|
||||
protected abstract void bakeBlock(@Nonnull B block, @Nonnull K key, @Nonnull IModelBaker baker, boolean inventory);
|
||||
|
||||
private class DefaultItemOverrideList extends ItemOverrideList {
|
||||
public DefaultItemOverrideList() {
|
||||
@@ -139,17 +187,7 @@ public abstract class ModelBlockDefault<B extends Block> implements IBakedModel
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
IModelBaker baker = new ModelBaker();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (!blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
B bBlock = blockClass.cast(block);
|
||||
|
||||
baker.setRenderBounds(block.getBoundingBox(block.getStateFromMeta(stack.getItemDamage()), world, null));
|
||||
bakeInventoryBlock(bBlock, stack, baker);
|
||||
|
||||
return itemModel = baker.bakeModel(true);
|
||||
return getModel(stack, world);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@
|
||||
package forestry.core.models;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -24,7 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -60,7 +60,7 @@ import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCrate extends BlankModel {
|
||||
|
||||
private static final Map<String, IBakedModel> cache = Maps.newHashMap();
|
||||
private static final Cache<String, IBakedModel> cache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).build();
|
||||
private static final String CUSTOM_CRATES = "forestry:item/crates/";
|
||||
|
||||
private static IModel crateModel;
|
||||
@@ -70,7 +70,7 @@ public class ModelCrate extends BlankModel {
|
||||
/**
|
||||
* Init the model with datas from the ModelBakeEvent.
|
||||
*/
|
||||
public static void initModel(ModelBakeEvent event){
|
||||
public static void onModelBake(ModelBakeEvent event){
|
||||
try {
|
||||
crateModel = ModelLoaderRegistry.getModel(new ResourceLocation("forestry:item/crate-filled"));
|
||||
MODEL_GENERATED = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.getModelLoader(), 17);
|
||||
@@ -78,7 +78,7 @@ public class ModelCrate extends BlankModel {
|
||||
} catch (Exception e) {
|
||||
Log.error("Failed to init the crate model.", e);
|
||||
}
|
||||
ModelCrate.cache.clear();
|
||||
ModelCrate.cache.invalidateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,7 +237,7 @@ public class ModelCrate extends BlankModel {
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
ItemCrated crated = (ItemCrated) stack.getItem();
|
||||
String crateUID = ItemStackUtil.getItemNameFromRegistry(crated).getResourcePath();
|
||||
if (cache.get(crateUID) == null) {
|
||||
if (cache.getIfPresent(crateUID) == null) {
|
||||
IBakedModel baseBaked = getModel(new ItemStack(PluginStorage.items.crate, 1, 1));
|
||||
//Set the crate color index to 100
|
||||
for (BakedQuad quad : baseBaked.getQuads(null, null, 0)) {
|
||||
@@ -246,7 +246,7 @@ public class ModelCrate extends BlankModel {
|
||||
|
||||
cache.put(crateUID, new IPerspectiveAwareModel.MapWrapper(new CrateBakedModel( bakeModel(crated, baseBaked)), ModelManager.getInstance().DEFAULT_ITEM));
|
||||
}
|
||||
return cache.get(crateUID);
|
||||
return cache.getIfPresent(crateUID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ package forestry.core.models.baker;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.api.core.IModelBakerModel;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@@ -28,18 +28,15 @@ import net.minecraft.client.renderer.block.model.FaceBakery;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.api.core.IModelBakerModel;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
/**
|
||||
* A model baker to make custom models in the mod
|
||||
@@ -50,8 +47,8 @@ public class ModelBaker implements IModelBaker {
|
||||
private static final float quadsUV[] = new float[]{0, 0, 1, 1, 0, 0, 1, 1};
|
||||
private final List<ModelBakerFace> faces = new ArrayList<>();
|
||||
private final List<Pair<IBlockState, IBakedModel>> bakedModels = new ArrayList<>();
|
||||
|
||||
protected AxisAlignedBB renderBounds;
|
||||
@Nonnull
|
||||
protected AxisAlignedBB renderBounds = Block.FULL_BLOCK_AABB;
|
||||
|
||||
protected ModelBakerModel currentModel = new ModelBakerModel(ModelManager.getInstance().DEFAULT_BLOCK);
|
||||
|
||||
|
||||
@@ -56,7 +56,10 @@ public enum PacketIdClient implements IPacketId {
|
||||
// Mail
|
||||
TRADING_ADDRESS_RESPONSE,
|
||||
LETTER_INFO_RESPONSE,
|
||||
POBOX_INFO_RESPONSE;
|
||||
POBOX_INFO_RESPONSE,
|
||||
|
||||
// JEI
|
||||
RECIPE_TRANSFER_UPDATE;
|
||||
|
||||
public static final PacketIdClient[] VALUES = values();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public enum PacketIdServer implements IPacketId {
|
||||
|
||||
// JEI
|
||||
WORKTABLE_RECIPE_REQUEST,
|
||||
RECIPE_TRANSFER_REQUEST,
|
||||
|
||||
// Apiculture
|
||||
BEE_LOGIC_ACTIVE_ENTITY_REQUEST,
|
||||
|
||||
@@ -76,12 +76,13 @@ public class PacketCamouflageSelectClient extends PacketCoordinates implements I
|
||||
|
||||
if (controller instanceof ICamouflageHandler) {
|
||||
handler = (ICamouflageHandler) controller;
|
||||
handler.setCamouflageBlock(camouflageType, camouflageStack);
|
||||
for (IMultiblockComponent comp : controller.getComponents()) {
|
||||
if (comp instanceof ICamouflagedTile) {
|
||||
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
|
||||
if (camouflageType != null && camBlock.getCamouflageType() != null && camBlock.getCamouflageType().equals(camouflageType)) {
|
||||
player.worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
|
||||
if(handler.setCamouflageBlock(camouflageType, camouflageStack, false)){
|
||||
for (IMultiblockComponent comp : controller.getComponents()) {
|
||||
if (comp instanceof ICamouflagedTile) {
|
||||
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
|
||||
if (camouflageType != null && camBlock.getCamouflageType() != null && camBlock.getCamouflageType().equals(camouflageType)) {
|
||||
player.worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,13 +91,10 @@ public class PacketCamouflageSelectClient extends PacketCoordinates implements I
|
||||
}else if(selectionType == CamouflageSelectionType.TILE){
|
||||
if (tile instanceof ICamouflageHandler) {
|
||||
handler = (ICamouflageHandler) tile;
|
||||
handler.setCamouflageBlock(camouflageType, camouflageStack);
|
||||
player.worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
if(handler.setCamouflageBlock(camouflageType, camouflageStack, false)){
|
||||
player.worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (handler != null) {
|
||||
handler.setCamouflageBlock(camouflageType, camouflageStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,8 +96,7 @@ public class PacketCamouflageSelectServer extends PacketCoordinates implements I
|
||||
}
|
||||
|
||||
if (handler != null) {
|
||||
handler.setCamouflageBlock(camouflageType, camouflageStack);
|
||||
if(selectionType != CamouflageSelectionType.ITEM){
|
||||
if(handler.setCamouflageBlock(camouflageType, camouflageStack, true) && selectionType != CamouflageSelectionType.ITEM){
|
||||
Proxies.net.sendNetworkPacket(new PacketCamouflageSelectClient(handler, camouflageType, selectionType), player.worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-14
@@ -14,40 +14,42 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class FontColour {
|
||||
|
||||
//private static final ResourceLocation colourDefinitions = new ForestryResource("/config/forestry/colour.properties");
|
||||
public class ColourProperties implements IResourceManagerReloadListener {
|
||||
|
||||
public static final ColourProperties INSTANCE;
|
||||
|
||||
static{
|
||||
INSTANCE = new ColourProperties();
|
||||
}
|
||||
|
||||
private final Properties defaultMappings = new Properties();
|
||||
private final Properties mappings = new Properties();
|
||||
|
||||
public FontColour(IResourceManager texturepack) {
|
||||
load(texturepack);
|
||||
private ColourProperties() {
|
||||
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(this);
|
||||
}
|
||||
|
||||
public synchronized int get(String key) {
|
||||
return Integer.parseInt(mappings.getProperty(key, defaultMappings.getProperty(key, "d67fff")), 16);
|
||||
}
|
||||
|
||||
public void load(IResourceManager texturepack) {
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
try {
|
||||
//InputStream fontStream = texturepack.func_110536_a(colourDefinitions).func_110527_b();
|
||||
InputStream defaultFontStream = FontColour.class.getResourceAsStream("/config/forestry/colour.properties");
|
||||
//mappings.load((fontStream == null) ? defaultFontStream : fontStream);
|
||||
InputStream defaultFontStream = ColourProperties.class.getResourceAsStream("/config/forestry/colour.properties");
|
||||
mappings.load(defaultFontStream);
|
||||
defaultMappings.load(defaultFontStream);
|
||||
|
||||
//if (fontStream != null)
|
||||
// fontStream.close();
|
||||
defaultFontStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to load font colors.", e);
|
||||
Log.error("Failed to load colors.properties.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.render;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -19,7 +20,7 @@ import net.minecraftforge.fluids.IFluidTank;
|
||||
public class TankRenderInfo {
|
||||
public static final TankRenderInfo EMPTY = new TankRenderInfo(new FluidStack(FluidRegistry.WATER, 0), EnumTankLevel.EMPTY);
|
||||
|
||||
@Nonnull
|
||||
@Nullable
|
||||
private final FluidStack fluidStack;
|
||||
@Nonnull
|
||||
private final EnumTankLevel level;
|
||||
@@ -28,12 +29,12 @@ public class TankRenderInfo {
|
||||
this(fluidTank.getFluid(), EnumTankLevel.rateTankLevel(fluidTank));
|
||||
}
|
||||
|
||||
public TankRenderInfo(@Nonnull FluidStack fluidStack, @Nonnull EnumTankLevel level) {
|
||||
public TankRenderInfo(@Nullable FluidStack fluidStack, @Nonnull EnumTankLevel level) {
|
||||
this.fluidStack = fluidStack;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Nullable
|
||||
public FluidStack getFluidStack() {
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CamouflageUtil {
|
||||
|
||||
public static void readCamouflageBlockFromNBT(NBTTagCompound data, ICamouflageHandler handler, String type){
|
||||
if(data.hasKey("Camouflage" + type)){
|
||||
handler.setCamouflageBlock(type, ItemStack.loadItemStackFromNBT(data.getCompoundTag("Camouflage" + type)));
|
||||
handler.setCamouflageBlock(type, ItemStack.loadItemStackFromNBT(data.getCompoundTag("Camouflage" + type)), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CamouflageUtil {
|
||||
|
||||
public static void readCamouflageBlockFromData(DataInputStreamForestry data, ICamouflageHandler handler) throws IOException{
|
||||
if(data.readShort() == 1){
|
||||
handler.setCamouflageBlock(data.readUTF(), data.readItemStack());
|
||||
handler.setCamouflageBlock(data.readUTF(), data.readItemStack(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IClimateHelper;
|
||||
import forestry.core.climate.ClimateRoom;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class ClimateUtil implements IClimateHelper {
|
||||
|
||||
@@ -203,4 +209,25 @@ public class ClimateUtil implements IClimateHelper {
|
||||
public String toDisplay(EnumHumidity humidity) {
|
||||
return Translator.translateToLocal("for.gui." + humidity.toString().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static void writeRoomPositionData(IClimatePosition position, DataOutputStreamForestry data) throws IOException {
|
||||
data.writeInt(position.getPos().getX());
|
||||
data.writeInt(position.getPos().getY());
|
||||
data.writeInt(position.getPos().getZ());
|
||||
writePositionData(position, data);
|
||||
}
|
||||
|
||||
public static void writePositionData(IClimatePosition position, DataOutputStreamForestry data) throws IOException {
|
||||
data.writeFloat(position.getTemperature());
|
||||
data.writeFloat(position.getHumidity());
|
||||
}
|
||||
|
||||
public static void readRoomPositionData(ClimateRoom room, DataInputStreamForestry data) throws IOException {
|
||||
room.addPosition(new BlockPos(data.readInt(), data.readInt(), data.readInt()), data.readFloat(), data.readFloat());
|
||||
}
|
||||
|
||||
public static void readPositionData(IClimatePosition position, DataInputStreamForestry data) throws IOException {
|
||||
position.setHumidity(data.readFloat());
|
||||
position.setTemperature(data.readFloat());
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
package forestry.energy.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
@@ -25,6 +25,11 @@ public class InventoryEngineBiogas extends InventoryAdapterTile<TileEngineBiogas
|
||||
super(engineBronze, 1, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, EnumFacing side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
|
||||
@@ -356,14 +356,21 @@ public class PluginFactory extends BlankForestryPlugin {
|
||||
'Y', PluginCore.items.sturdyCasing);
|
||||
|
||||
// / CHIPSETS
|
||||
ItemCircuitBoard circuitBoard = PluginCore.items.circuitboards;
|
||||
RecipeManagers.carpenterManager.addRecipe(20, new FluidStack(FluidRegistry.WATER, 1000), null, ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.BASIC, null, new ICircuit[]{}),
|
||||
ItemStack basicCircuitboard = ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.BASIC, null, new ICircuit[]{});
|
||||
ItemStack enhancedCircuitboard = ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.ENHANCED, null, new ICircuit[]{});
|
||||
ItemStack refinedCircuitboard = ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.REFINED, null, new ICircuit[]{});
|
||||
ItemStack intricateCircuitboard = ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.INTRICATE, null, new ICircuit[]{});
|
||||
|
||||
RecipeManagers.carpenterManager.addRecipe(20, new FluidStack(FluidRegistry.WATER, 1000), null, basicCircuitboard,
|
||||
"R R", "R#R", "R R", '#', "ingotTin", 'R', "dustRedstone");
|
||||
RecipeManagers.carpenterManager.addRecipe(40, new FluidStack(FluidRegistry.WATER, 1000), null, ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.ENHANCED, null, new ICircuit[]{}),
|
||||
|
||||
RecipeManagers.carpenterManager.addRecipe(40, new FluidStack(FluidRegistry.WATER, 1000), null, enhancedCircuitboard,
|
||||
"R#R", "R#R", "R#R", '#', "ingotBronze", 'R', "dustRedstone");
|
||||
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), null, ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.REFINED, null, new ICircuit[]{}),
|
||||
|
||||
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), null, refinedCircuitboard,
|
||||
"R#R", "R#R", "R#R", '#', "ingotIron", 'R', "dustRedstone");
|
||||
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), null, ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.INTRICATE, null, new ICircuit[]{}),
|
||||
|
||||
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), null, intricateCircuitboard,
|
||||
"R#R", "R#R", "R#R", '#', "ingotGold", 'R', "dustRedstone");
|
||||
RecipeManagers.carpenterManager.addRecipe(40, new FluidStack(FluidRegistry.WATER, 1000), null, PluginCore.items.solderingIron.getItemStack(),
|
||||
" # ", "# #", " B", '#', "ingotIron", 'B', "ingotBronze");
|
||||
|
||||
@@ -78,4 +78,8 @@ public class ContainerCarpenter extends ContainerLiquidTanks<TileCarpenter> impl
|
||||
}
|
||||
}
|
||||
|
||||
public TileCarpenter getCarpenter() {
|
||||
return tile;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,4 +73,8 @@ public class ContainerFabricator extends ContainerLiquidTanks<TileFabricator> im
|
||||
tile.sendGUINetworkData(this, crafter);
|
||||
}
|
||||
}
|
||||
|
||||
public TileFabricator getFabricator(){
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@
|
||||
package forestry.factory.network;
|
||||
|
||||
import forestry.core.network.PacketRegistry;
|
||||
import forestry.factory.network.packets.PacketRecipeTransferRequest;
|
||||
import forestry.factory.network.packets.PacketRecipeTransferUpdate;
|
||||
import forestry.factory.network.packets.PacketWorktableMemoryUpdate;
|
||||
import forestry.factory.network.packets.PacketWorktableRecipeRequest;
|
||||
import forestry.factory.network.packets.PacketWorktableRecipeUpdate;
|
||||
@@ -21,7 +23,9 @@ public class PacketRegistryFactory extends PacketRegistry {
|
||||
|
||||
registerClientPacket(new PacketWorktableMemoryUpdate());
|
||||
registerClientPacket(new PacketWorktableRecipeUpdate());
|
||||
registerClientPacket(new PacketRecipeTransferUpdate());
|
||||
|
||||
registerServerPacket(new PacketWorktableRecipeRequest());
|
||||
registerServerPacket(new PacketRecipeTransferRequest());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*******************************************************************************
|
||||
* 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.factory.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.network.packets.PacketCoordinates;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.factory.tiles.TileCarpenter;
|
||||
import forestry.factory.tiles.TileFabricator;
|
||||
|
||||
public class PacketRecipeTransferRequest extends PacketCoordinates implements IForestryPacketServer {
|
||||
private ItemStack[] craftingInventory;
|
||||
|
||||
public PacketRecipeTransferRequest() {
|
||||
}
|
||||
|
||||
public PacketRecipeTransferRequest(TileBase base, ItemStack[] craftingInventory) {
|
||||
super(base);
|
||||
this.craftingInventory = craftingInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeItemStacks(craftingInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
craftingInventory = data.readItemStacks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
TileEntity tile = getTarget(player.worldObj);
|
||||
if (tile instanceof TileCarpenter) {
|
||||
TileCarpenter carpenter = (TileCarpenter) tile;
|
||||
int index = 0;
|
||||
for(ItemStack stack : craftingInventory){
|
||||
carpenter.getCraftingInventory().setInventorySlotContents(index, stack);
|
||||
index++;
|
||||
}
|
||||
|
||||
Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(carpenter, craftingInventory), player.worldObj);
|
||||
}else if(tile instanceof TileFabricator){
|
||||
TileFabricator fabricator = (TileFabricator) tile;
|
||||
int index = 0;
|
||||
for(ItemStack stack : craftingInventory){
|
||||
fabricator.getCraftingInventory().setInventorySlotContents(index, stack);
|
||||
index++;
|
||||
}
|
||||
|
||||
Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(fabricator, craftingInventory), player.worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketIdServer getPacketId() {
|
||||
return PacketIdServer.RECIPE_TRANSFER_REQUEST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************
|
||||
* 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.factory.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.network.packets.PacketCoordinates;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.factory.tiles.TileCarpenter;
|
||||
import forestry.factory.tiles.TileFabricator;
|
||||
|
||||
public class PacketRecipeTransferUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
private ItemStack[] craftingInventory;
|
||||
|
||||
public PacketRecipeTransferUpdate() {
|
||||
}
|
||||
|
||||
public PacketRecipeTransferUpdate(TileBase base, ItemStack[] craftingInventory) {
|
||||
super(base);
|
||||
this.craftingInventory = craftingInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeItemStacks(craftingInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
craftingInventory = data.readItemStacks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(player.worldObj);
|
||||
if (tile instanceof TileCarpenter) {
|
||||
TileCarpenter carpenter = (TileCarpenter) tile;
|
||||
int index = 0;
|
||||
for(ItemStack stack : craftingInventory){
|
||||
carpenter.getCraftingInventory().setInventorySlotContents(index, stack);
|
||||
index++;
|
||||
}
|
||||
}else if(tile instanceof TileFabricator){
|
||||
TileFabricator fabricator = (TileFabricator) tile;
|
||||
int index = 0;
|
||||
for(ItemStack stack : craftingInventory){
|
||||
fabricator.getCraftingInventory().setInventorySlotContents(index, stack);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketIdClient getPacketId() {
|
||||
return PacketIdClient.RECIPE_TRANSFER_UPDATE;
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,14 @@ import forestry.factory.recipes.jei.bottler.BottlerRecipeMaker;
|
||||
import forestry.factory.recipes.jei.carpenter.CarpenterRecipeCategory;
|
||||
import forestry.factory.recipes.jei.carpenter.CarpenterRecipeHandler;
|
||||
import forestry.factory.recipes.jei.carpenter.CarpenterRecipeMaker;
|
||||
import forestry.factory.recipes.jei.carpenter.CarpenterRecipeTransferHandler;
|
||||
import forestry.factory.recipes.jei.centrifuge.CentrifugeRecipeCategory;
|
||||
import forestry.factory.recipes.jei.centrifuge.CentrifugeRecipeHandler;
|
||||
import forestry.factory.recipes.jei.centrifuge.CentrifugeRecipeMaker;
|
||||
import forestry.factory.recipes.jei.fabricator.FabricatorRecipeCategory;
|
||||
import forestry.factory.recipes.jei.fabricator.FabricatorRecipeHandler;
|
||||
import forestry.factory.recipes.jei.fabricator.FabricatorRecipeMaker;
|
||||
import forestry.factory.recipes.jei.fabricator.FabricatorRecipeTransferHandler;
|
||||
import forestry.factory.recipes.jei.fermenter.FermenterRecipeCategory;
|
||||
import forestry.factory.recipes.jei.fermenter.FermenterRecipeHandler;
|
||||
import forestry.factory.recipes.jei.fermenter.FermenterRecipeMaker;
|
||||
@@ -127,6 +129,8 @@ public class FactoryJeiPlugin extends BlankModPlugin {
|
||||
|
||||
IRecipeTransferRegistry transferRegistry = registry.getRecipeTransferRegistry();
|
||||
transferRegistry.addRecipeTransferHandler(new WorktableRecipeTransferHandler());
|
||||
transferRegistry.addRecipeTransferHandler(new CarpenterRecipeTransferHandler());
|
||||
transferRegistry.addRecipeTransferHandler(new FabricatorRecipeTransferHandler());
|
||||
|
||||
registry.addAdvancedGuiHandlers(new ForestryAdvancedGuiHandler());
|
||||
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package forestry.factory.recipes.jei.carpenter;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.gui.ContainerCarpenter;
|
||||
import forestry.factory.network.packets.PacketRecipeTransferRequest;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CarpenterRecipeTransferHandler implements IRecipeTransferHandler<ContainerCarpenter> {
|
||||
|
||||
@Override
|
||||
public Class<ContainerCarpenter> getContainerClass() {
|
||||
return ContainerCarpenter.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return ForestryRecipeCategoryUid.CARPENTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(ContainerCarpenter container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
|
||||
if(doTransfer){
|
||||
IInventory craftingInventory = container.getCarpenter().getCraftingInventory();
|
||||
ItemStack[] items = new ItemStack[9];
|
||||
for(Entry<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredientEntry : recipeLayout.getItemStacks().getGuiIngredients().entrySet()){
|
||||
IGuiIngredient<ItemStack> guiIngredient = guiIngredientEntry.getValue();
|
||||
if(guiIngredientEntry != null && guiIngredient.getDisplayedIngredient() != null){
|
||||
int index = guiIngredientEntry.getKey();
|
||||
if (index >= 2) {
|
||||
ItemStack ingredient = guiIngredient.getDisplayedIngredient().copy();
|
||||
craftingInventory.setInventorySlotContents(index - 2, ingredient);
|
||||
items[index - 2] = ingredient;
|
||||
}
|
||||
}
|
||||
}
|
||||
Proxies.net.sendToServer(new PacketRecipeTransferRequest(container.getCarpenter(), items));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package forestry.factory.recipes.jei.fabricator;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.gui.ContainerFabricator;
|
||||
import forestry.factory.network.packets.PacketRecipeTransferRequest;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FabricatorRecipeTransferHandler implements IRecipeTransferHandler<ContainerFabricator> {
|
||||
|
||||
@Override
|
||||
public Class<ContainerFabricator> getContainerClass() {
|
||||
return ContainerFabricator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return ForestryRecipeCategoryUid.FABRICATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(ContainerFabricator container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
|
||||
if(doTransfer){
|
||||
IInventory craftingInventory = container.getFabricator().getCraftingInventory();
|
||||
ItemStack[] items = new ItemStack[9];
|
||||
for(Entry<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredientEntry : recipeLayout.getItemStacks().getGuiIngredients().entrySet()){
|
||||
IGuiIngredient<ItemStack> guiIngredient = guiIngredientEntry.getValue();
|
||||
int index = guiIngredientEntry.getKey();
|
||||
if (index >= 3 && guiIngredientEntry != null && guiIngredient.getDisplayedIngredient() != null) {
|
||||
ItemStack ingredient =guiIngredient.getDisplayedIngredient().copy();
|
||||
craftingInventory.setInventorySlotContents(index - 3, ingredient);
|
||||
items[index - 3] = ingredient;
|
||||
}
|
||||
}
|
||||
Proxies.net.sendToServer(new PacketRecipeTransferRequest(container.getFabricator(), items));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package forestry.factory.recipes.jei.squeezer;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
|
||||
@@ -118,12 +118,11 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
if (tryAddPending()) {
|
||||
setCurrentPreviewItem();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!pendingProducts.isEmpty()) {
|
||||
setCurrentPreviewItem();
|
||||
craftPreviewInventory.setInventorySlotContents(0, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -134,10 +133,13 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
|
||||
// We are done, add products to queue
|
||||
Collection<ItemStack> products = currentRecipe.getProducts(worldObj.rand);
|
||||
pendingProducts.addAll(products);
|
||||
|
||||
getInternalInventory().decrStackSize(InventoryCentrifuge.SLOT_RESOURCE, 1);
|
||||
|
||||
setCurrentPreviewItem();
|
||||
//Add Item to preview slot.
|
||||
ItemStack previewStack = getInternalInventory().getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).copy();
|
||||
previewStack.stackSize=1;
|
||||
craftPreviewInventory.setInventorySlotContents(0, previewStack);
|
||||
|
||||
getInternalInventory().decrStackSize(InventoryCentrifuge.SLOT_RESOURCE, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -166,6 +168,9 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
|
||||
|
||||
if (added) {
|
||||
pendingProducts.pop();
|
||||
if(pendingProducts.isEmpty()){
|
||||
craftPreviewInventory.setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NO_SPACE_INVENTORY);
|
||||
@@ -265,14 +270,6 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
|
||||
public IInventory getCraftPreviewInventory() {
|
||||
return craftPreviewInventory;
|
||||
}
|
||||
|
||||
private void setCurrentPreviewItem(){
|
||||
if(!pendingProducts.isEmpty()){
|
||||
craftPreviewInventory.setInventorySlotContents(0, pendingProducts.peek());
|
||||
}else{
|
||||
craftPreviewInventory.setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItemStackForDisplay(ItemStack itemStack) {
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.farming;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockBeetroot;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.block.BlockNetherWart;
|
||||
@@ -30,7 +29,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.CircuitSocketType;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
@@ -246,7 +244,7 @@ public class PluginFarming extends BlankForestryPlugin {
|
||||
ChipsetManager.solderManager.addRecipe(layoutManual, PluginCore.items.tubes.get(EnumElectronTube.APATITE, 1), Circuit.farmShroomManual);
|
||||
ChipsetManager.solderManager.addRecipe(layoutManual, PluginCore.items.tubes.get(EnumElectronTube.LAPIS, 1), Circuit.farmCocoaManual);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getHiddenItems(List<ItemStack> hiddenItems) {
|
||||
// mushrooms are a workaround for the farm and should not be obtainable
|
||||
|
||||
@@ -1,62 +1,91 @@
|
||||
package forestry.farming.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import java.util.Objects;
|
||||
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.models.ModelBlockDefault;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.farming.blocks.BlockFarm;
|
||||
import forestry.farming.blocks.EnumFarmBlockType;
|
||||
import forestry.farming.tiles.TileFarm;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
public class ModelFarmBlock extends ModelBlockDefault<BlockFarm> {
|
||||
public class ModelFarmBlock extends ModelBlockCached<BlockFarm, ModelFarmBlock.Key> {
|
||||
public static class Key {
|
||||
public final EnumFarmBlockTexture texture;
|
||||
public final EnumFarmBlockType type;
|
||||
private final int hashCode;
|
||||
|
||||
public Key(EnumFarmBlockTexture texture, EnumFarmBlockType type) {
|
||||
this.texture = texture;
|
||||
this.type = type;
|
||||
this.hashCode = Objects.hash(texture, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null || !(other instanceof Key)) {
|
||||
return false;
|
||||
} else {
|
||||
Key otherKey = (Key) other;
|
||||
return otherKey.texture == texture && otherKey.type == type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public ModelFarmBlock() {
|
||||
super(BlockFarm.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bakeInventoryBlock(@Nonnull BlockFarm blockFarm, @Nonnull ItemStack item, @Nonnull IModelBaker baker) {
|
||||
if (blockFarm == null) {
|
||||
return;
|
||||
}
|
||||
protected Key getInventoryKey(@Nonnull ItemStack stack) {
|
||||
EnumFarmBlockTexture texture = EnumFarmBlockTexture.getFromCompound(stack.getTagCompound());
|
||||
EnumFarmBlockType type = EnumFarmBlockType.VALUES[stack.getItemDamage()];
|
||||
|
||||
EnumFarmBlockTexture type = EnumFarmBlockTexture.getFromCompound(item.getTagCompound());
|
||||
|
||||
// Add the plain block.
|
||||
baker.addBlockModel(blockFarm, Block.FULL_BLOCK_AABB, null, getSprites(type), 0);
|
||||
// Add the overlay block.
|
||||
baker.addBlockModel(blockFarm, Block.FULL_BLOCK_AABB, null, getOverlaySprites(EnumFarmBlockType.VALUES[item.getItemDamage()]), 0);
|
||||
return new Key(texture, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bakeWorldBlock(@Nonnull BlockFarm blockFarm, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IExtendedBlockState stateExtended, @Nonnull IModelBaker baker) {
|
||||
protected Key getWorldKey(@Nonnull IBlockState state) {
|
||||
IExtendedBlockState stateExtended = (IExtendedBlockState) state;
|
||||
IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
|
||||
BlockPos pos = stateExtended.getValue(UnlistedBlockPos.POS);
|
||||
|
||||
TileFarm farm = TileUtil.getTile(world, pos, TileFarm.class);
|
||||
|
||||
EnumFarmBlockTexture texture = EnumFarmBlockTexture.BRICK;
|
||||
TextureAtlasSprite[] overlayTextures = getOverlaySprites(EnumFarmBlockType.PLAIN);
|
||||
|
||||
if(farm != null){
|
||||
EnumFarmBlockType type = EnumFarmBlockType.PLAIN;
|
||||
|
||||
if (farm != null) {
|
||||
texture = farm.getFarmBlockTexture();
|
||||
overlayTextures = getOverlaySprites(farm.getFarmBlockType());
|
||||
type = farm.getFarmBlockType();
|
||||
}
|
||||
|
||||
TextureAtlasSprite[] textures = getSprites(texture);
|
||||
|
||||
return new Key(texture, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeBlock(@Nonnull BlockFarm blockFarm, @Nonnull Key key, @Nonnull IModelBaker baker, boolean inventory) {
|
||||
TextureAtlasSprite[] textures = getSprites(key.texture);
|
||||
|
||||
// Add the plain block.
|
||||
baker.addBlockModel(blockFarm, Block.FULL_BLOCK_AABB, pos, textures, 0);
|
||||
baker.addBlockModel(blockFarm, Block.FULL_BLOCK_AABB, null, textures, 0);
|
||||
// Add the overlay block.
|
||||
baker.addBlockModel(blockFarm, Block.FULL_BLOCK_AABB, pos, overlayTextures, 0);
|
||||
|
||||
baker.addBlockModel(blockFarm, Block.FULL_BLOCK_AABB, null, getOverlaySprites(key.type), 0);
|
||||
|
||||
// Set the particle sprite
|
||||
baker.setParticleSprite(textures[0]);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import forestry.api.food.BeverageManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.food.inventory.ItemInventoryInfuser;
|
||||
|
||||
public class GuiInfuser extends GuiForestry<ContainerInfuser, ItemInventoryInfuser> {
|
||||
@@ -40,7 +41,7 @@ public class GuiInfuser extends GuiForestry<ContainerInfuser, ItemInventoryInfus
|
||||
}
|
||||
|
||||
int row = (l - 2) * 20;
|
||||
fontRendererObj.drawString(description, startX + 32, startY + 16 + row, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(description, startX + 32, startY + 16 + row, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.gui.widgets.WidgetCamouflageSlot;
|
||||
import forestry.core.network.packets.PacketUpdateClimateControl;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.greenhouse.multiblock.DefaultClimateControl;
|
||||
@@ -154,12 +155,12 @@ public class GuiGreenhouse extends GuiForestryTitled<ContainerGreenhouse, TileGr
|
||||
|
||||
if(temperatureField.getVisible()){
|
||||
textLayout.line = 20;
|
||||
textLayout.drawCenteredLine(Translator.translateToLocal("for.gui.temperature"), 0, fontColor.get("gui.greenhouse.temperature.text"));
|
||||
textLayout.drawCenteredLine(Translator.translateToLocal("for.gui.temperature"), 0, ColourProperties.INSTANCE.get("gui.greenhouse.temperature.text"));
|
||||
temperatureField.drawTextBox();
|
||||
}
|
||||
if(humidityField.getVisible()){
|
||||
textLayout.line = 50;
|
||||
textLayout.drawCenteredLine(Translator.translateToLocal("for.gui.humidity"), 0, fontColor.get("gui.greenhouse.humidity.text"));
|
||||
textLayout.drawCenteredLine(Translator.translateToLocal("for.gui.humidity"), 0, ColourProperties.INSTANCE.get("gui.greenhouse.humidity.text"));
|
||||
|
||||
humidityField.drawTextBox();
|
||||
}
|
||||
|
||||
@@ -11,70 +11,89 @@
|
||||
package forestry.greenhouse.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.ModelBlockDefault;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ModelGreenhouse extends ModelBlockDefault<BlockGreenhouse> {
|
||||
// DO NOT CACHE THIS. PLEASE. I BEG YOU. NOT IN THE CURRENT STATE.
|
||||
public class ModelGreenhouse extends ModelBlockDefault<BlockGreenhouse, ModelGreenhouse.Key> {
|
||||
public static class Key {
|
||||
public final IExtendedBlockState state;
|
||||
public final IBlockAccess world;
|
||||
public final BlockPos pos;
|
||||
|
||||
public Key(IExtendedBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
this.state = state;
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
}
|
||||
}
|
||||
|
||||
public ModelGreenhouse() {
|
||||
super(BlockGreenhouse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeInventoryBlock(@Nonnull BlockGreenhouse block, @Nonnull ItemStack item, @Nonnull IModelBaker baker) {
|
||||
bakeBlockModel(block, null, null, null, baker, null);
|
||||
protected Key getInventoryKey(@Nonnull ItemStack stack) {
|
||||
return new Key(null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeWorldBlock(@Nonnull BlockGreenhouse block, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IExtendedBlockState stateExtended, @Nonnull IModelBaker baker) {
|
||||
ItemStack camouflageStack = CamouflageUtil.getCamouflageBlock(world, pos);
|
||||
|
||||
bakeBlockModel(block, world, pos, stateExtended, baker, camouflageStack);
|
||||
protected Key getWorldKey(@Nonnull IBlockState state) {
|
||||
IExtendedBlockState stateExtended = (IExtendedBlockState) state;
|
||||
IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
|
||||
BlockPos pos = stateExtended.getValue(UnlistedBlockPos.POS);
|
||||
return new Key(stateExtended, world, pos);
|
||||
}
|
||||
|
||||
private static void bakeBlockModel(@Nonnull BlockGreenhouse block, @Nullable IBlockAccess world, @Nullable BlockPos pos, @Nullable IExtendedBlockState stateExtended, @Nonnull IModelBaker baker, @Nullable ItemStack camouflageStack) {
|
||||
|
||||
@Override
|
||||
protected void bakeBlock(@Nonnull BlockGreenhouse block, @Nonnull Key key, @Nonnull IModelBaker baker, boolean inventory) {
|
||||
ItemStack camouflageStack = key.world != null ? CamouflageUtil.getCamouflageBlock(key.world, key.pos) : null;
|
||||
IBlockAccess world = key.world;
|
||||
BlockPos pos = key.pos;
|
||||
|
||||
if (camouflageStack != null) {
|
||||
ICamouflageHandler camouflageHandler = CamouflageUtil.getCamouflageHandler(world, pos);
|
||||
ICamouflagedTile camouflageTile = (ICamouflagedTile) world.getTileEntity(pos);
|
||||
ICamouflageItemHandler itemHandler = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflageStack);
|
||||
if(itemHandler != null){
|
||||
Pair<IBlockState, IBakedModel> model = itemHandler.getModel(camouflageStack, camouflageHandler, camouflageTile);
|
||||
|
||||
baker.addBakedModel(model.getLeft(), model.getRight());
|
||||
baker.setParticleSprite(model.getRight().getParticleTexture());
|
||||
|
||||
if(model != null){
|
||||
baker.addBakedModel(model.getLeft(), model.getRight());
|
||||
baker.setParticleSprite(model.getRight().getParticleTexture());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Bake the default blocks
|
||||
else if (block.getGreenhouseType() == BlockGreenhouseType.GLASS) {
|
||||
TextureAtlasSprite glassSprite = BlockGreenhouseType.getSprite(BlockGreenhouseType.GLASS, null, null, world, pos);
|
||||
|
||||
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, BlockGreenhouseType.getSprite(BlockGreenhouseType.GLASS, null, null, world, pos), 100);
|
||||
baker.setParticleSprite(glassSprite);
|
||||
} else {
|
||||
TextureAtlasSprite plainSprite = BlockGreenhouseType.getSprite(BlockGreenhouseType.PLAIN, null, null, world, pos);
|
||||
|
||||
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, BlockGreenhouseType.getSprite(BlockGreenhouseType.PLAIN, null, null, world, pos), 100);
|
||||
baker.setParticleSprite(plainSprite);
|
||||
}
|
||||
@@ -82,10 +101,9 @@ public class ModelGreenhouse extends ModelBlockDefault<BlockGreenhouse> {
|
||||
if (block.getGreenhouseType().hasOverlaySprite) {
|
||||
TextureAtlasSprite[] sprite = new TextureAtlasSprite[6];
|
||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||
sprite[facing.ordinal()] = BlockGreenhouseType.getSprite(block.getGreenhouseType(), facing, stateExtended, world, pos);
|
||||
sprite[facing.ordinal()] = BlockGreenhouseType.getSprite(block.getGreenhouseType(), facing, key.state, world, pos);
|
||||
}
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, sprite, 101);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,8 +67,8 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
|
||||
public boolean setCamouflageBlock(String type, ItemStack camouflageBlock, boolean sendClientUpdate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -266,7 +266,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
/* CAMOUFLAGE */
|
||||
@Override
|
||||
public void setCamouflageBlock(String type, ItemStack camouflageBlock) {
|
||||
public boolean setCamouflageBlock(String type, ItemStack camouflageBlock, boolean sendClientUpdate) {
|
||||
ItemStack oldCamouflageBlock;
|
||||
switch (type) {
|
||||
case CamouflageManager.DEFAULT:
|
||||
@@ -279,7 +279,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
oldCamouflageBlock = camouflageDoorBlock;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, oldCamouflageBlock)){
|
||||
@@ -294,14 +294,15 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
camouflageDoorBlock = camouflageBlock;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (worldObj != null && worldObj.isRemote) {
|
||||
if (sendClientUpdate && worldObj != null && worldObj.isRemote) {
|
||||
Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.MULTIBLOCK));
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, null, this, type));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user