mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 17:44:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
202d19df93 | ||
|
|
333334190a | ||
|
|
7c00ea2965 | ||
|
|
79cf866a96 | ||
|
|
504ec8acfc | ||
|
|
44a926f897 | ||
|
|
30d7365518 | ||
|
|
56800af94d | ||
|
|
043571b659 | ||
|
|
7fd2776147 | ||
|
|
d4c2d7220d | ||
|
|
d392666dc4 | ||
|
|
07b88d36fc | ||
|
|
408d1dc7c3 | ||
|
|
7b1aead339 | ||
|
|
21969649a2 | ||
|
|
f9b8b89340 | ||
|
|
65712adcb3 | ||
|
|
9864a84a13 | ||
|
|
8f9ae45147 | ||
|
|
2965f28403 | ||
|
|
cb93c217e0 | ||
|
|
219e9bf355 | ||
|
|
43a2f0ae76 | ||
|
|
098b739dca | ||
|
|
4dfa29b1ad | ||
|
|
60d2820ed6 | ||
|
|
91ec6cff9b | ||
|
|
1775e59880 | ||
|
|
f62745b233 | ||
|
|
1d6293c788 | ||
|
|
3fd07f2a7a | ||
|
|
856e800e0e | ||
|
|
d9561fd7af | ||
|
|
e0623f7d57 | ||
|
|
d48b979ac3 | ||
|
|
63494c40a7 | ||
|
|
2c57aef3b3 | ||
|
|
1392823fae | ||
|
|
67693961ac | ||
|
|
8ad8597ff0 | ||
|
|
4c8d5e2f43 | ||
|
|
d04713339c | ||
|
|
844aea7431 | ||
|
|
53a9bf458e | ||
|
|
2ae52451b2 | ||
|
|
d3054c33e7 | ||
|
|
bf61462a2a | ||
|
|
41f3ae4b1f | ||
|
|
b1d7c1721d | ||
|
|
2944165741 | ||
|
|
e316526675 | ||
|
|
411cbd913c | ||
|
|
2191d00f3d | ||
|
|
a02af0ddf2 | ||
|
|
a8e4f5dde7 | ||
|
|
85718b1df8 | ||
|
|
781b4d883b | ||
|
|
c5c056750a | ||
|
|
3b8af4e4c9 | ||
|
|
f58938ff32 | ||
|
|
a05bc13852 | ||
|
|
1cd3e15ef9 | ||
|
|
1ac7a7de42 | ||
|
|
90ed57c742 | ||
|
|
94b0b44f51 | ||
|
|
c0fafc20da | ||
|
|
4f85236475 |
No files matched your search
+8
-11
@@ -1,14 +1,7 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
maven { url = "http://files.minecraftforge.net/maven" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
@@ -16,11 +9,10 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "net.minecraftforge.gradle.forge" version "2.0.2"
|
||||
id "com.matthewprenger.cursegradle" version "1.0.7"
|
||||
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "1.32"
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'maven'
|
||||
|
||||
version = version_major + '.' + version_minor + '.' + version_patch + '.' + getBuildNumber()
|
||||
@@ -98,6 +90,9 @@ processResources {
|
||||
exclude 'mcmod.info'
|
||||
exclude '**/*.md'
|
||||
}
|
||||
|
||||
// Move access transformers to META-INF
|
||||
rename '(.+_at.cfg)', 'META-INF/$1'
|
||||
}
|
||||
|
||||
// prevent java 8's strict doclint for javadocs from failing builds
|
||||
@@ -108,7 +103,9 @@ allprojects {
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
manifest {
|
||||
attributes 'FMLAT': 'forestry_at.cfg'
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
mcversion=1.10.2
|
||||
forgeversion=12.18.1.2094
|
||||
mcp_mappings=snapshot_20160525
|
||||
forgeversion=12.18.2.2125
|
||||
mcp_mappings=snapshot_20161111
|
||||
|
||||
tesla_version=1.10.2-1.2.1.49
|
||||
jei_version=3.12.2.290
|
||||
jei_version=3.13.2.349
|
||||
ic2_version=2.6.76-ex110
|
||||
|
||||
version_major=5
|
||||
version_minor=2
|
||||
version_patch=15
|
||||
version_patch=17
|
||||
+1
-1
Submodule lang updated: 6a30635d3f...e919e4ad51.
@@ -13,9 +13,9 @@ import java.util.Set;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IIndividualLiving;
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ public interface IBee extends IIndividualLiving {
|
||||
|
||||
void plantFlowerRandom(IBeeHousing housing);
|
||||
|
||||
ITree retrievePollen(IBeeHousing housing);
|
||||
IIndividual retrievePollen(IBeeHousing housing);
|
||||
|
||||
boolean pollinateRandom(IBeeHousing housing, ITree pollen);
|
||||
boolean pollinateRandom(IBeeHousing housing, IIndividual pollen);
|
||||
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
@@ -20,9 +22,11 @@ import forestry.api.genetics.IGenome;
|
||||
public interface IBeeGenome extends IGenome {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
IAlleleBeeSpecies getPrimary();
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
IAlleleBeeSpecies getSecondary();
|
||||
|
||||
float getSpeed();
|
||||
|
||||
@@ -35,6 +35,8 @@ public interface IBeeHousing extends IHousing, IErrorLogicSource, IClimateProvid
|
||||
int getBlockLightValue();
|
||||
|
||||
boolean canBlockSeeTheSky();
|
||||
|
||||
boolean isRaining();
|
||||
|
||||
GameProfile getOwner();
|
||||
|
||||
|
||||
@@ -26,4 +26,12 @@ public interface IGermlingModelProvider {
|
||||
|
||||
@Nonnull
|
||||
ModelResourceLocation getModel(EnumGermlingType type);
|
||||
|
||||
/**
|
||||
* Provides color for sapling. See {@link ILeafSpriteProvider} for pollen color.
|
||||
* @param type the germling type to render
|
||||
* @param renderPass renderPass of rendering
|
||||
* @return sapling color for renderPass
|
||||
*/
|
||||
int getSpriteColor(EnumGermlingType type, int renderPass);
|
||||
}
|
||||
@@ -12,9 +12,11 @@ import forestry.api.genetics.IGenome;
|
||||
public interface ITreeGenome extends IGenome {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
IAlleleTreeSpecies getPrimary();
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
IAlleleTreeSpecies getSecondary();
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -13,13 +14,13 @@ import java.util.List;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.ISpeciesRootPollinatable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ITreeRoot extends ISpeciesRoot {
|
||||
public interface ITreeRoot extends ISpeciesRootPollinatable {
|
||||
|
||||
@Override
|
||||
boolean isMember(ItemStack itemstack);
|
||||
@@ -78,7 +79,7 @@ public interface ITreeRoot extends ISpeciesRoot {
|
||||
@Override
|
||||
IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, BlockPos pos);
|
||||
boolean setFruitBlock(@Nonnull World world, @Nonnull IAlleleFruit allele, float sappiness, BlockPos pos);
|
||||
|
||||
/* GAME MODE */
|
||||
List<ITreekeepingMode> getTreekeepingModes();
|
||||
|
||||
@@ -13,8 +13,9 @@ public interface IClimateSource {
|
||||
/**
|
||||
* @param tickCount The current tick count.
|
||||
* @param region The climate region, in that the source stands.
|
||||
* @return Return true if the the climate has changed.
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateRegion region);
|
||||
boolean changeClimate(int tickCount, IClimateRegion region);
|
||||
|
||||
/**
|
||||
* @return The ticks that are required for one change.
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -27,7 +26,10 @@ public interface IErrorState {
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerSprite();
|
||||
|
||||
@SideOnly(value = Side.CLIENT)
|
||||
/**
|
||||
* Sprite registered to the Gui Texture Map at {@link ITextureManager}
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
TextureAtlasSprite getSprite();
|
||||
|
||||
}
|
||||
@@ -6,13 +6,29 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Get the instance from {@link ForestryAPI#textureManager}.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ITextureManager {
|
||||
|
||||
/**
|
||||
* Location of the Forestry Gui Texture Map.
|
||||
* Used for binding with {@link net.minecraft.client.renderer.texture.TextureManager#bindTexture(ResourceLocation)}
|
||||
*/
|
||||
ResourceLocation getGuiTextureMap();
|
||||
|
||||
/**
|
||||
* Get a texture atlas sprite that has been registered by Forestry, for Forestry's Gui Texture Map.
|
||||
*/
|
||||
TextureAtlasSprite getDefault(String ident);
|
||||
|
||||
/**
|
||||
* Register a sprite with Forestry's Gui Texture Map.
|
||||
*/
|
||||
TextureAtlasSprite registerGuiSprite(ResourceLocation location);
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion = "5.0.0", owner = "Forestry", provides = "ForestryAPI|core")
|
||||
@API(apiVersion = "5.1.0", owner = "Forestry", provides = "ForestryAPI|core")
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -8,6 +8,10 @@ package forestry.api.farming;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class Farmables {
|
||||
@@ -18,5 +22,8 @@ public class Farmables {
|
||||
*/
|
||||
@Nonnull
|
||||
public static final Multimap<String, IFarmable> farmables = HashMultimap.create();
|
||||
|
||||
@Nonnull
|
||||
public static final LinkedHashMap<ItemStack, Integer> fertilizers = new LinkedHashMap();
|
||||
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
/**
|
||||
@@ -28,7 +27,7 @@ public interface ICheckPollinatable {
|
||||
/**
|
||||
* @return IIndividual containing the genetic information of this IPollinatable
|
||||
*/
|
||||
ITree getPollen();
|
||||
IIndividual getPollen();
|
||||
|
||||
/**
|
||||
* Checks whether this can mate with the given pollen.
|
||||
@@ -38,7 +37,7 @@ public interface ICheckPollinatable {
|
||||
* @param pollen IIndividual representing the pollen.
|
||||
* @return true if mating is possible, false otherwise.
|
||||
*/
|
||||
boolean canMateWith(ITree pollen);
|
||||
boolean canMateWith(IIndividual pollen);
|
||||
|
||||
/**
|
||||
* @return true if this has already been pollinated.
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.INbtWritable;
|
||||
|
||||
/**
|
||||
@@ -14,17 +16,23 @@ import forestry.api.core.INbtWritable;
|
||||
*/
|
||||
public interface IGenome extends INbtWritable {
|
||||
|
||||
@Nonnull
|
||||
IAlleleSpecies getPrimary();
|
||||
|
||||
@Nonnull
|
||||
IAlleleSpecies getSecondary();
|
||||
|
||||
@Nonnull
|
||||
IChromosome[] getChromosomes();
|
||||
|
||||
@Nonnull
|
||||
IAllele getActiveAllele(IChromosomeType chromosomeType);
|
||||
|
||||
@Nonnull
|
||||
IAllele getInactiveAllele(IChromosomeType chromosomeType);
|
||||
|
||||
boolean isGeneticEqual(IGenome other);
|
||||
|
||||
|
||||
@Nonnull
|
||||
ISpeciesRoot getSpeciesRoot();
|
||||
}
|
||||
@@ -5,8 +5,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
|
||||
/**
|
||||
* Can be implemented by tile entities, if they wish to be pollinatable.
|
||||
*
|
||||
@@ -20,5 +18,5 @@ public interface IPollinatable extends ICheckPollinatable {
|
||||
* @param pollen
|
||||
* IIndividual representing the pollen.
|
||||
*/
|
||||
void mateWith(ITree pollen);
|
||||
void mateWith(IIndividual pollen);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package forestry.api.genetics;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @since 5.12.16
|
||||
* @author Nedelosk
|
||||
*/
|
||||
public interface ISpeciesRootPollinatable extends ISpeciesRoot {
|
||||
|
||||
ICheckPollinatable createPollinatable(IIndividual individual);
|
||||
|
||||
IPollinatable tryConvertToPollinatable(GameProfile owner, World world, final BlockPos pos, final IIndividual pollen);
|
||||
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.lepidopterology;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IGenome;
|
||||
@@ -12,9 +14,11 @@ import forestry.api.genetics.IGenome;
|
||||
public interface IButterflyGenome extends IGenome {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
IAlleleButterflySpecies getPrimary();
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
IAlleleButterflySpecies getSecondary();
|
||||
|
||||
float getSize();
|
||||
|
||||
@@ -8,7 +8,7 @@ package forestry.api.lepidopterology;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.passive.IAnimals;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public interface IEntityButterfly extends IAnimals {
|
||||
|
||||
@@ -23,9 +23,9 @@ public interface IEntityButterfly extends IAnimals {
|
||||
*/
|
||||
EntityCreature getEntity();
|
||||
|
||||
ITree getPollen();
|
||||
IIndividual getPollen();
|
||||
|
||||
void setPollen(ITree pollen);
|
||||
void setPollen(IIndividual pollen);
|
||||
|
||||
boolean canMateWith(IEntityButterfly butterfly);
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.mail;
|
||||
|
||||
import forestry.api.core.ITextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -31,6 +31,10 @@ public interface IPostalCarrier {
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Sprite registered to the Gui Texture Map at {@link ITextureManager}.
|
||||
* Must be 26 pixels wide and 15 pixels tall. The texture itself must be 32x32 square.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
TextureAtlasSprite getSprite();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion = "3.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|mail")
|
||||
@API(apiVersion = "3.1.0", owner = "ForestryAPI|core", provides = "ForestryAPI|mail")
|
||||
package forestry.api.mail;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -38,10 +39,10 @@ import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.network.packets.PacketBeeLogicActive;
|
||||
import forestry.apiculture.network.packets.PacketBeeLogicActiveEntity;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -195,7 +196,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
queenStack = null;
|
||||
}
|
||||
|
||||
if (!ItemStack.areItemStacksEqual(this.queenStack, queenStack)) {
|
||||
if (this.queenStack != queenStack) {
|
||||
this.queen = BeeManager.beeRoot.getMember(queenStack);
|
||||
this.queenStack = queenStack;
|
||||
hasFlowersCache.clear();
|
||||
@@ -486,6 +487,9 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
|
||||
@Override
|
||||
public boolean canDoBeeFX() {
|
||||
if(Proxies.common.getClientInstance().isGamePaused()){
|
||||
return false;
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
||||
@@ -528,7 +532,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
private static class PollenHandler {
|
||||
private static final int MAX_POLLINATION_ATTEMPTS = 20;
|
||||
|
||||
private ITree pollen;
|
||||
private IIndividual pollen;
|
||||
private int attemptedPollinations = 0;
|
||||
|
||||
public void doPollination(IBee queen, IBeeHousing beeHousing, IBeeListener beeListener) {
|
||||
|
||||
@@ -320,6 +320,8 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
|
||||
// Register acceptable plants
|
||||
flowerRegistry.registerAcceptableFlower(Blocks.DRAGON_EGG, FlowerManager.FlowerTypeEnd);
|
||||
flowerRegistry.registerAcceptableFlower(Blocks.CHORUS_PLANT, FlowerManager.FlowerTypeEnd);
|
||||
flowerRegistry.registerAcceptableFlower(Blocks.CHORUS_FLOWER, FlowerManager.FlowerTypeEnd);
|
||||
flowerRegistry.registerAcceptableFlower(Blocks.VINE, FlowerManager.FlowerTypeJungle);
|
||||
flowerRegistry.registerAcceptableFlower(Blocks.TALLGRASS, FlowerManager.FlowerTypeJungle);
|
||||
flowerRegistry.registerAcceptableFlower(Blocks.WHEAT, FlowerManager.FlowerTypeWheat);
|
||||
|
||||
@@ -120,7 +120,8 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
if (((TileCandle) world.getTileEntity(pos)).isLit()) {
|
||||
TileCandle tileCandle = TileUtil.getTile(world, pos, TileCandle.class);
|
||||
if (tileCandle != null && tileCandle.isLit()) {
|
||||
state = state.withProperty(STATE, State.ON);
|
||||
}
|
||||
return super.getActualState(state, world, pos);
|
||||
|
||||
@@ -129,12 +129,17 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
|
||||
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
return worldObj.getLightFromNeighbors(getPosition().add(0, +1, 0));
|
||||
return worldObj.getLightFromNeighbors(getPosition().up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return worldObj.canBlockSeeSky(getPosition().add(0, +1, 0));
|
||||
return worldObj.canBlockSeeSky(getPosition().up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRaining() {
|
||||
return worldObj.isRainingAt(getPosition().up());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -167,6 +167,9 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
|
||||
|
||||
List<BlockPos> flowerCoords = new ArrayList<>();
|
||||
for (BlockPos.MutableBlockPos posBlock : VectUtil.getAllInBoxFromCenterMutable(world, minPos, beeHousing.getCoordinates(), maxPos)) {
|
||||
if (!world.isBlockLoaded(posBlock)) {
|
||||
continue;
|
||||
}
|
||||
IBlockState blockState = world.getBlockState(posBlock);
|
||||
if (blockState.getBlock().isAir(blockState, world, posBlock)) {
|
||||
continue;
|
||||
@@ -194,6 +197,9 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(String flowerType, World world, BlockPos pos) {
|
||||
if (!world.isBlockLoaded(pos)) {
|
||||
return true; // Avoid actually checking until the flower's position is loaded.
|
||||
}
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
Set<IFlowerAcceptableRule> acceptedCustom = this.registeredRules.get(flowerType);
|
||||
for (IFlowerAcceptableRule acceptableFlower : acceptedCustom) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
|
||||
if (!world.isAirBlock(pos)) {
|
||||
if (!world.isBlockLoaded(pos) || !world.isAirBlock(pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ public class GrowthRuleFertilize implements IFlowerGrowthRule {
|
||||
}
|
||||
|
||||
private boolean growFlower(World world, BlockPos pos) {
|
||||
if (!world.isBlockLoaded(pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block ground = state.getBlock();
|
||||
int groundMeta;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GrowthRuleMycelium implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
|
||||
if (!world.isAirBlock(pos)) {
|
||||
if (!world.isBlockLoaded(pos) || !world.isAirBlock(pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GrowthRuleSnow implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
|
||||
if (world.getBlockState(pos).getBlock() != Blocks.SNOW) {
|
||||
if (!world.isBlockLoaded(pos) || world.getBlockState(pos).getBlock() != Blocks.SNOW) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorState;
|
||||
@@ -254,7 +253,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
// / Rain needs tolerant flyers
|
||||
if (world.isRainingAt(housingCoords.up()) && !canFlyInRain(beeModifier)) {
|
||||
if (housing.isRaining() && !canFlyInRain(beeModifier)) {
|
||||
errorStates.add(EnumErrorCode.IS_RAINING);
|
||||
}
|
||||
|
||||
@@ -666,7 +665,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
/* FLOWERS */
|
||||
@Override
|
||||
public ITree retrievePollen(IBeeHousing housing) {
|
||||
public IIndividual retrievePollen(IBeeHousing housing) {
|
||||
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
@@ -684,7 +683,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
|
||||
BlockPos housingPos = housing.getCoordinates();
|
||||
|
||||
ITree pollen = null;
|
||||
IIndividual pollen = null;
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area);
|
||||
@@ -709,7 +708,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pollinateRandom(IBeeHousing housing, ITree pollen) {
|
||||
public boolean pollinateRandom(IBeeHousing housing, IIndividual pollen) {
|
||||
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
|
||||
@@ -98,11 +98,13 @@ public class BeeGenome extends Genome implements IBeeGenome {
|
||||
|
||||
// / INFORMATION RETRIEVAL
|
||||
@Override
|
||||
@Nonnull
|
||||
public IAlleleBeeSpecies getPrimary() {
|
||||
return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IAlleleBeeSpecies getSecondary() {
|
||||
return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES);
|
||||
}
|
||||
@@ -168,6 +170,7 @@ public class BeeGenome extends Genome implements IBeeGenome {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return BeeManager.beeRoot;
|
||||
}
|
||||
|
||||
@@ -45,11 +45,13 @@ public class AlleleEffectFertile extends AlleleEffectThrottled {
|
||||
int blockMinY = housingCoordinates.getY() - area.getY() / 2 - 1;
|
||||
|
||||
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
|
||||
if (tryTickColumn(world, blockX, blockZ, blockMaxY, blockMinY)) {
|
||||
break;
|
||||
if (world.getChunkProvider().getLoadedChunk(blockX >> 4, blockZ >> 4) != null) {
|
||||
if (tryTickColumn(world, blockX, blockZ, blockMaxY, blockMinY)) {
|
||||
break;
|
||||
}
|
||||
blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
|
||||
blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
|
||||
}
|
||||
blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
|
||||
blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
|
||||
}
|
||||
|
||||
return storedData;
|
||||
|
||||
@@ -61,12 +61,14 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
|
||||
|
||||
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
|
||||
BlockPos pos = VectUtil.getRandomPositionInArea(world.rand, area).subtract(halfArea).add(housingCoordinates);
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (world.isBlockLoaded(pos)) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
|
||||
if (convertToMycelium(world, blockState, pos)) {
|
||||
return;
|
||||
} else if (growGiantMushroom(world, blockState, pos)) {
|
||||
return;
|
||||
if (convertToMycelium(world, blockState, pos)) {
|
||||
return;
|
||||
} else if (growGiantMushroom(world, blockState, pos)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,16 +52,14 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
|
||||
BlockPos posBlock = VectUtil.add(randomPos, housingCoords, offset);
|
||||
|
||||
// Freeze water
|
||||
Block block = world.getBlockState(posBlock).getBlock();
|
||||
if (block != Blocks.WATER) {
|
||||
continue;
|
||||
if (world.isBlockLoaded(posBlock)) {
|
||||
Block block = world.getBlockState(posBlock).getBlock();
|
||||
if (block == Blocks.WATER) {
|
||||
if (world.isAirBlock(new BlockPos(posBlock.getX(), posBlock.getY() + 1, posBlock.getZ()))) {
|
||||
world.setBlockState(posBlock, Blocks.ICE.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isAirBlock(new BlockPos(posBlock.getX(), posBlock.getY() + 1, posBlock.getZ()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
world.setBlockState(posBlock, Blocks.ICE.getDefaultState());
|
||||
}
|
||||
|
||||
return storedData;
|
||||
|
||||
@@ -84,7 +84,7 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (world.isAirBlock(posBlock)) {
|
||||
if (!world.isBlockLoaded(posBlock) || world.isAirBlock(posBlock)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
|
||||
|
||||
BlockPos posBlock = randomPos.add(housing.getCoordinates());
|
||||
posBlock = posBlock.add(offset);
|
||||
if (!world.isBlockLoaded(posBlock)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Put snow on the ground
|
||||
if (!world.isSideSolid(new BlockPos(posBlock.getX(), posBlock.getY() - 1, posBlock.getZ()), EnumFacing.UP, false)) {
|
||||
|
||||
@@ -17,8 +17,6 @@ import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -70,7 +68,7 @@ public class HabitatSlot extends Widget {
|
||||
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap());
|
||||
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, getIcon(), 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,6 +397,12 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
BlockPos topCenter = getTopCenterCoord();
|
||||
return worldObj.canBlockSeeSky(topCenter.add(0, 2, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRaining() {
|
||||
BlockPos topCenter = getTopCenterCoord();
|
||||
return worldObj.isRainingAt(topCenter.add(0, 2, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
|
||||
@@ -66,6 +66,11 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRaining() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
|
||||
@@ -135,6 +135,11 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry<Multibloc
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return getMultiblockLogic().getController().canBlockSeeTheSky();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRaining() {
|
||||
return getMultiblockLogic().getController().isRaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
|
||||
@@ -185,6 +185,11 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return worldObj.canBlockSeeSky(getPos().up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRaining() {
|
||||
return worldObj.isRainingAt(getPos().up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
|
||||
@@ -331,6 +331,11 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return true; // hives may have the sky obstructed but should still be active
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRaining() {
|
||||
return worldObj.isRainingAt(getPos().up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorldObj() {
|
||||
|
||||
@@ -15,27 +15,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
@@ -62,6 +41,25 @@ import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
|
||||
public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
@@ -88,13 +86,15 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
}
|
||||
|
||||
private void createBuildingBlocks(Random random) {
|
||||
boolean fireproof = random.nextInt(4) == 0;
|
||||
IWoodType woodType;
|
||||
boolean fireproof;
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
|
||||
woodType = EnumForestryWoodType.getRandom(random);
|
||||
fireproof = random.nextInt(4) == 0;
|
||||
} else {
|
||||
woodType = EnumVanillaWoodType.getRandom(random);
|
||||
fireproof = false;
|
||||
}
|
||||
|
||||
IWoodAccess woodAccess = TreeManager.woodAccess;
|
||||
@@ -107,9 +107,9 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
this.fenceGate = woodAccess.getBlock(woodType, WoodBlockKind.FENCE_GATE, fireproof);
|
||||
}
|
||||
|
||||
public static VillageApiaristHouse buildComponent(StructureVillagePieces.Start startPiece, List<StructureComponent> par1List, Random random, int structureMinX, int structureMinY, int structureMinZ, EnumFacing facing, int componentType) {
|
||||
public static VillageApiaristHouse buildComponent(StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int structureMinX, int structureMinY, int structureMinZ, EnumFacing facing, int componentType) {
|
||||
StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(structureMinX, structureMinY, structureMinZ, -4, 0, 0, 12, 9, 12, facing);
|
||||
if (!canVillageGoDeeper(bbox) || StructureComponent.findIntersecting(par1List, bbox) != null) {
|
||||
if (!canVillageGoDeeper(bbox) || StructureComponent.findIntersecting(pieces, bbox) != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
private void buildGarden(World world, StructureBoundingBox box) {
|
||||
|
||||
Block ground = Blocks.DIRT;
|
||||
if (field_189928_h == 1) { // desert
|
||||
if (structureType == 1) { // desert
|
||||
ground = Blocks.SAND;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
private void plantFlowerGarden(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
|
||||
if (field_189928_h == 1) { // desert
|
||||
if (structureType == 1) { // desert
|
||||
setBlockState(world, Blocks.CACTUS.getDefaultState(), 4, 1, 7, box);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -148,6 +148,14 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
CapabilityManager.INSTANCE.register(IArmorNaturalist.class, new NullStorage<>(), () -> ArmorNaturalist.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disabledSetupAPI() {
|
||||
TreeManager.woodAccess = new WoodAccess();
|
||||
|
||||
// Capabilities
|
||||
CapabilityManager.INSTANCE.register(IArmorNaturalist.class, new NullStorage<>(), () -> ArmorNaturalist.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemsAndBlocks() {
|
||||
items = new ItemRegistryArboriculture();
|
||||
@@ -425,7 +433,7 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
//Dirt Pile Block
|
||||
RecipeUtil.addShapelessRecipe(new ItemStack(PluginArboriculture.blocks.piles.get(EnumPileType.DIRT)), PluginCore.items.fertilizerBio, Items.CLAY_BALL, PluginCore.items.fertilizerBio, OreDictUtil.DIRT, OreDictUtil.DIRT, OreDictUtil.DIRT, PluginCore.items.fertilizerBio, Items.CLAY_BALL, PluginCore.items.fertilizerBio);
|
||||
RecipeUtil.addShapelessRecipe(new ItemStack(PluginArboriculture.blocks.piles.get(EnumPileType.DIRT), 4), Items.CLAY_BALL, PluginCore.items.fertilizerBio, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, PluginCore.items.fertilizerBio, Items.CLAY_BALL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package forestry.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
@@ -19,16 +18,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockNewLog;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.BlockWoodSlab;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodAccess;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
@@ -41,7 +30,15 @@ import forestry.arboriculture.blocks.log.BlockForestryLog;
|
||||
import forestry.arboriculture.blocks.planks.BlockForestryPlanks;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.arboriculture.blocks.slab.BlockForestrySlab;
|
||||
import forestry.core.utils.Log;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockNewLog;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.BlockWoodSlab;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class WoodAccess implements IWoodAccess {
|
||||
private static final Map<WoodBlockKind, WoodMap> woodMaps = new EnumMap<>(WoodBlockKind.class);
|
||||
@@ -242,8 +239,8 @@ public class WoodAccess implements IWoodAccess {
|
||||
WoodMap woodMap = woodMaps.get(woodBlockKind);
|
||||
ItemStack itemStack = woodMap.getItem(fireproof).get(woodType);
|
||||
if (itemStack == null) {
|
||||
Log.error("No stack found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : "");
|
||||
return null;
|
||||
String errMessage = String.format("No stack found for %s %s %s", woodType, woodMap.getName(), fireproof ? "fireproof" : "non-fireproof");
|
||||
throw new IllegalStateException(errMessage);
|
||||
}
|
||||
return itemStack.copy();
|
||||
}
|
||||
@@ -256,8 +253,8 @@ public class WoodAccess implements IWoodAccess {
|
||||
WoodMap woodMap = woodMaps.get(woodBlockKind);
|
||||
IBlockState blockState = woodMap.getBlock(fireproof).get(woodType);
|
||||
if (blockState == null) {
|
||||
Log.error("No block found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : "non-fireproof");
|
||||
return null;
|
||||
String errMessage = String.format("No block found for %s %s %s", woodType, woodMap.getName(), fireproof ? "fireproof" : "non-fireproof");
|
||||
throw new IllegalStateException(errMessage);
|
||||
}
|
||||
return blockState;
|
||||
}
|
||||
|
||||
@@ -52,10 +52,6 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
|
||||
/* PROPERTYS */
|
||||
public static final PropertyTree TREE = new PropertyTree("tree");
|
||||
|
||||
public static TileSapling getSaplingTile(IBlockAccess world, BlockPos pos) {
|
||||
return TileUtil.getTile(world, pos, TileSapling.class);
|
||||
}
|
||||
|
||||
public BlockSapling() {
|
||||
super(Material.PLANTS);
|
||||
@@ -105,7 +101,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileSapling sapling = getSaplingTile(world, pos);
|
||||
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if(sapling != null && sapling.getTree() != null){
|
||||
state = state.withProperty(TREE, sapling.getTree().getGenome().getPrimary());
|
||||
}else{
|
||||
@@ -135,7 +131,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
|
||||
/* PLANTING */
|
||||
public static boolean canBlockStay(IBlockAccess world, BlockPos pos) {
|
||||
TileSapling tile = getSaplingTile(world, pos);
|
||||
TileSapling tile = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -165,7 +161,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
TileSapling sapling = getSaplingTile(world, pos);
|
||||
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if (sapling == null || sapling.getTree() == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -188,7 +184,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
return;
|
||||
}
|
||||
|
||||
TileSapling sapling = getSaplingTile(world, pos);
|
||||
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if (sapling != null && sapling.getTree() != null) {
|
||||
ItemStack saplingStack = TreeManager.treeRoot.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING);
|
||||
ItemStackUtil.dropItemStackAsEntity(saplingStack, world, pos);
|
||||
@@ -202,7 +198,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
if (world.rand.nextFloat() >= 0.45F) {
|
||||
return false;
|
||||
}
|
||||
TileSapling saplingTile = getSaplingTile(world, pos);
|
||||
TileSapling saplingTile = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if (saplingTile != null) {
|
||||
return saplingTile.canAcceptBoneMeal(rand);
|
||||
}
|
||||
@@ -216,7 +212,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
|
||||
@Override
|
||||
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
|
||||
TileSapling saplingTile = getSaplingTile(world, pos);
|
||||
TileSapling saplingTile = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if (saplingTile != null) {
|
||||
saplingTile.tryGrow(rand, true);
|
||||
}
|
||||
|
||||
@@ -967,7 +967,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
this.branch = branch;
|
||||
|
||||
ILeafSpriteProvider leafIconProvider = TreeManager.treeFactory.getLeafIconProvider(leafType, primary, secondary);
|
||||
IGermlingModelProvider germlingIconProvider = ModelProviderFactory.create(woodType, uid);
|
||||
IGermlingModelProvider germlingIconProvider = ModelProviderFactory.create(woodType, uid, leafIconProvider);
|
||||
IWoodProvider woodProvider = WoodProviderFactory.create(woodType);
|
||||
|
||||
IAlleleTreeSpeciesBuilder speciesBuilder = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, Constants.MOD_ID, leafIconProvider, germlingIconProvider, woodProvider, this);
|
||||
|
||||
@@ -53,11 +53,13 @@ public class TreeGenome extends Genome implements ITreeGenome {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IAlleleTreeSpecies getPrimary() {
|
||||
return (IAlleleTreeSpecies) getActiveAllele(EnumTreeChromosome.SPECIES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IAlleleTreeSpecies getSecondary() {
|
||||
return (IAlleleTreeSpecies) getInactiveAllele(EnumTreeChromosome.SPECIES);
|
||||
}
|
||||
@@ -104,6 +106,7 @@ public class TreeGenome extends Genome implements ITreeGenome {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return TreeManager.treeRoot;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.genetics;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -34,15 +35,19 @@ import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlyzerPlugin;
|
||||
import forestry.api.genetics.ICheckPollinatable;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.api.genetics.ISpeciesType;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.blocks.BlockFruitPod;
|
||||
import forestry.arboriculture.blocks.BlockSapling;
|
||||
import forestry.arboriculture.genetics.pollination.CheckPollinatableTree;
|
||||
import forestry.arboriculture.tiles.TileFruitPod;
|
||||
import forestry.arboriculture.tiles.TileSapling;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.genetics.SpeciesRoot;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -235,7 +240,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, BlockPos pos) {
|
||||
public boolean setFruitBlock(@Nonnull World world, @Nonnull IAlleleFruit allele, float sappiness, BlockPos pos) {
|
||||
|
||||
EnumFacing facing = BlockUtil.getValidPodFacing(world, pos);
|
||||
if (facing == null) {
|
||||
@@ -428,4 +433,23 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
return TreeAlyzerPlugin.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICheckPollinatable createPollinatable(IIndividual individual) {
|
||||
if(individual instanceof ITree){
|
||||
return new CheckPollinatableTree((ITree)individual);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPollinatable tryConvertToPollinatable(GameProfile owner, World world, BlockPos pos, IIndividual pollen) {
|
||||
if(pollen instanceof ITree){
|
||||
if (Config.pollinateVanillaTrees) {
|
||||
((ITree)pollen).setLeaves(world, owner, pos);
|
||||
return (IPollinatable) world.getTileEntity(pos);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,10 +140,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getGermlingColour(EnumGermlingType type, int renderPass) {
|
||||
if (type != EnumGermlingType.POLLEN) {
|
||||
return 0xFFFFFF;
|
||||
}
|
||||
return getSpriteColour(renderPass);
|
||||
return germlingModelProvider.getSpriteColor(type, renderPass);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
+9
-5
@@ -12,6 +12,7 @@ package forestry.arboriculture.genetics.pollination;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.ICheckPollinatable;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class CheckPollinatableTree implements ICheckPollinatable {
|
||||
@@ -33,12 +34,15 @@ public class CheckPollinatableTree implements ICheckPollinatable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMateWith(ITree pollen) {
|
||||
if (tree.getMate() != null) {
|
||||
return false;
|
||||
public boolean canMateWith(IIndividual pollen) {
|
||||
if(pollen instanceof ITree){
|
||||
if (tree.getMate() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !tree.isGeneticEqual(pollen);
|
||||
}
|
||||
|
||||
return !tree.isGeneticEqual(pollen);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,14 +5,15 @@ import javax.annotation.Nonnull;
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IGermlingModelProvider;
|
||||
import forestry.api.arboriculture.ILeafSpriteProvider;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
|
||||
public class ModelProviderFactory {
|
||||
public static IGermlingModelProvider create(@Nonnull IWoodType woodType, String modelUid) {
|
||||
public static IGermlingModelProvider create(@Nonnull IWoodType woodType, String modelUid, ILeafSpriteProvider leafSpriteProvider) {
|
||||
if (woodType instanceof EnumVanillaWoodType) {
|
||||
return new ModelProviderGermlingVanilla((EnumVanillaWoodType) woodType);
|
||||
return new ModelProviderGermlingVanilla((EnumVanillaWoodType) woodType, leafSpriteProvider);
|
||||
} else if (woodType instanceof EnumForestryWoodType) {
|
||||
return new ModelProviderGermling(modelUid);
|
||||
return new ModelProviderGermling(modelUid, leafSpriteProvider);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown wood type: " + woodType);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.arboriculture.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.arboriculture.ILeafSpriteProvider;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -27,12 +28,14 @@ import forestry.api.core.IModelManager;
|
||||
public class ModelProviderGermling implements IGermlingModelProvider {
|
||||
|
||||
private final String name;
|
||||
private final ILeafSpriteProvider leafSpriteProvider;
|
||||
|
||||
private ModelResourceLocation germlingModel;
|
||||
private ModelResourceLocation pollenModel;
|
||||
|
||||
public ModelProviderGermling(String modelUid) {
|
||||
public ModelProviderGermling(String modelUid, ILeafSpriteProvider leafSpriteProvider) {
|
||||
this.name = modelUid.substring("forestry.".length());
|
||||
this.leafSpriteProvider = leafSpriteProvider;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -56,4 +59,13 @@ public class ModelProviderGermling implements IGermlingModelProvider {
|
||||
return germlingModel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpriteColor(EnumGermlingType type, int renderPass) {
|
||||
if (type == EnumGermlingType.POLLEN) {
|
||||
return leafSpriteProvider.getColor(false);
|
||||
} else {
|
||||
return 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package forestry.arboriculture.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.arboriculture.ILeafSpriteProvider;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@@ -23,13 +24,15 @@ import forestry.api.core.IModelManager;
|
||||
public class ModelProviderGermlingVanilla implements IGermlingModelProvider {
|
||||
|
||||
private final EnumVanillaWoodType woodType;
|
||||
private final ILeafSpriteProvider leafSpriteProvider;
|
||||
|
||||
private ModelResourceLocation germlingModel;
|
||||
private ModelResourceLocation pollenModel;
|
||||
private ModelResourceLocation charcoalModel;
|
||||
|
||||
public ModelProviderGermlingVanilla(EnumVanillaWoodType woodType) {
|
||||
public ModelProviderGermlingVanilla(EnumVanillaWoodType woodType, ILeafSpriteProvider leafSpriteProvider) {
|
||||
this.woodType = woodType;
|
||||
this.leafSpriteProvider = leafSpriteProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,4 +72,13 @@ public class ModelProviderGermlingVanilla implements IGermlingModelProvider {
|
||||
return germlingModel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpriteColor(EnumGermlingType type, int renderPass) {
|
||||
if (type == EnumGermlingType.POLLEN) {
|
||||
return leafSpriteProvider.getColor(false);
|
||||
} else {
|
||||
return 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.Attributes;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.IRetexturableModel;
|
||||
@@ -224,9 +223,6 @@ public enum WoodModelLoader implements ICustomModelLoader{
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter){
|
||||
if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)){
|
||||
throw new IllegalArgumentException("can't bake vanilla weighted models to the format that doesn't fit into the default one: " + format);
|
||||
}
|
||||
if(variants.size() == 1){
|
||||
IModel model = models.get(0);
|
||||
return model.bake(MultiModelState.getPartState(state, model, 0), format, bakedTextureGetter);
|
||||
|
||||
@@ -95,6 +95,7 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
|
||||
protected void onMachineDisassembled() {
|
||||
setActive(false);
|
||||
burnTime = 0;
|
||||
woodBurnTime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +112,7 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
|
||||
if (!isActive()) {
|
||||
return false;
|
||||
}
|
||||
if(woodBurnTime == 0 && tickCount % 20 == 0){
|
||||
if(woodBurnTime == 0){
|
||||
int validComps = 0;
|
||||
int newBurnTime = 0;
|
||||
for (IMultiblockComponent part : connectedParts) {
|
||||
@@ -126,8 +127,8 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
|
||||
newBurnTime += charcoalAmount * 500;
|
||||
}
|
||||
}
|
||||
if(validComps <= 0){
|
||||
woodBurnTime = newBurnTime / validComps;
|
||||
if(validComps > 0){
|
||||
woodBurnTime = newBurnTime;
|
||||
}else{
|
||||
woodBurnTime = 0;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.block.BlockCocoa;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -43,8 +44,10 @@ import forestry.core.utils.NBTUtilForestry;
|
||||
public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamable {
|
||||
|
||||
private static final short MAX_MATURITY = 2;
|
||||
private static final IAlleleFruit defaultAllele = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele(Constants.MOD_ID + ".fruitCocoa");
|
||||
|
||||
private IAlleleFruit allele;
|
||||
@Nonnull
|
||||
private IAlleleFruit allele = defaultAllele;
|
||||
|
||||
private short maturity;
|
||||
private float sappiness;
|
||||
@@ -53,9 +56,10 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
Log.debug("Made a fruit pod");
|
||||
}
|
||||
|
||||
public void setProperties(IAlleleFruit allele, float sappiness) {
|
||||
public void setProperties(@Nonnull IAlleleFruit allele, float sappiness) {
|
||||
this.allele = allele;
|
||||
this.sappiness = sappiness;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@@ -67,21 +71,18 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
if (stored instanceof IAlleleFruit) {
|
||||
allele = (IAlleleFruit) stored;
|
||||
} else {
|
||||
allele = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele(Constants.MOD_ID + ".fruitCocoa");
|
||||
allele = defaultAllele;
|
||||
}
|
||||
|
||||
maturity = nbttagcompound.getShort("MT");
|
||||
sappiness = nbttagcompound.getFloat("SP");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (allele != null) {
|
||||
nbttagcompound.setString("UID", allele.getUID());
|
||||
}
|
||||
|
||||
nbttagcompound.setString("UID", allele.getUID());
|
||||
nbttagcompound.setShort("MT", maturity);
|
||||
nbttagcompound.setFloat("SP", sappiness);
|
||||
return nbttagcompound;
|
||||
@@ -115,8 +116,12 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
}
|
||||
}
|
||||
|
||||
pickBlock.stackSize = 1;
|
||||
return pickBlock;
|
||||
if (pickBlock == null) {
|
||||
return null;
|
||||
} else {
|
||||
pickBlock.stackSize = 1;
|
||||
return pickBlock;
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemStack> getDrops() {
|
||||
@@ -143,6 +148,13 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
NBTUtilForestry.readStreamableFromNbt(this, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
NBTTagCompound nbt = pkt.getNbtCompound();
|
||||
handleUpdateTag(nbt);
|
||||
}
|
||||
|
||||
/* IFRUITBEARER */
|
||||
@Override
|
||||
public boolean hasFruit() {
|
||||
@@ -194,7 +206,7 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
if (allele != null) {
|
||||
if (allele != defaultAllele) {
|
||||
data.writeUTF(allele.getUID());
|
||||
} else {
|
||||
data.writeUTF("");
|
||||
@@ -207,7 +219,7 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
if (stored instanceof IAlleleFruit) {
|
||||
allele = (IAlleleFruit) stored;
|
||||
} else {
|
||||
allele = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele(Constants.MOD_ID + ".fruitCocoa");
|
||||
allele = defaultAllele;
|
||||
}
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
|
||||
@@ -269,28 +269,33 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMateWith(ITree individual) {
|
||||
ITree tree = getTree();
|
||||
if (tree == null) {
|
||||
return false;
|
||||
public boolean canMateWith(IIndividual individual) {
|
||||
if(individual instanceof ITree){
|
||||
ITree tree = getTree();
|
||||
if (tree == null) {
|
||||
return false;
|
||||
}
|
||||
if (tree.getMate() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !tree.isGeneticEqual(individual);
|
||||
}
|
||||
if (tree.getMate() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !tree.isGeneticEqual(individual);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mateWith(ITree individual) {
|
||||
ITree tree = getTree();
|
||||
if (tree == null || worldObj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
tree.mate(individual);
|
||||
if (!worldObj.isRemote) {
|
||||
sendNetworkUpdate();
|
||||
public void mateWith(IIndividual individual) {
|
||||
if(individual instanceof ITree){
|
||||
ITree tree = getTree();
|
||||
if (tree == null || worldObj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
tree.mate((ITree) individual);
|
||||
if (!worldObj.isRemote) {
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+17
-28
@@ -10,33 +10,27 @@
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.loot.LootTableLoader;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.packets.PacketGenomeTrackerRequest;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.plugins.PluginManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.loot.LootPool;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.event.LootTableLoadEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.loot.LootTableLoader;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
public class EventHandlerCore {
|
||||
|
||||
public EventHandlerCore() {
|
||||
@@ -45,7 +39,7 @@ public class EventHandlerCore {
|
||||
@SubscribeEvent
|
||||
public void handleItemPickup(EntityItemPickupEvent event) {
|
||||
|
||||
if (event.isCanceled()) {
|
||||
if (event.isCanceled() || event.getResult() == Result.ALLOW) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,22 +51,17 @@ public class EventHandlerCore {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
Collection<ISpeciesRoot> speciesRoots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
|
||||
for (ISpeciesRoot speciesRoot : speciesRoots) {
|
||||
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.getEntityWorld(), player.getGameProfile());
|
||||
breedingTracker.synchToPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handleWorldLoad(WorldEvent.Load event) {
|
||||
World world = event.getWorld();
|
||||
|
||||
for (ISaveEventHandler handler : PluginManager.saveEventHandlers) {
|
||||
handler.onWorldLoad(event.getWorld());
|
||||
handler.onWorldLoad(world);
|
||||
}
|
||||
|
||||
if (world.isRemote) {
|
||||
IForestryPacketServer packet = new PacketGenomeTrackerRequest();
|
||||
world.sendPacketToServer(packet.getPacket());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ package forestry.core.climate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
@@ -27,22 +27,151 @@ public class ClimateEventHandler {
|
||||
public ClimateEventHandler() {
|
||||
serverTicks = new HashMap<>();
|
||||
}
|
||||
|
||||
//Climate test mode
|
||||
/*public static Pair<BlockPos, BlockPos> recalculateMinMaxCoords(Collection<BlockPos> positions) {
|
||||
BlockPos minimumCoord = new BlockPos(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
BlockPos maximumCoord = new BlockPos(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
|
||||
for (BlockPos position : positions) {
|
||||
int minX = minimumCoord.getX();
|
||||
int minY = minimumCoord.getY();
|
||||
int minZ = minimumCoord.getZ();
|
||||
int maxX = maximumCoord.getX();
|
||||
int maxY = maximumCoord.getY();
|
||||
int maxZ = maximumCoord.getZ();
|
||||
if (position.getX() < minimumCoord.getX()) {
|
||||
minX = position.getX();
|
||||
}
|
||||
if (position.getX() > maximumCoord.getX()) {
|
||||
maxX = position.getX();
|
||||
}
|
||||
if (position.getY() < minimumCoord.getY()) {
|
||||
minY = position.getY();
|
||||
}
|
||||
if (position.getY() > maximumCoord.getY()) {
|
||||
maxY = position.getY();
|
||||
}
|
||||
if (position.getZ() < minimumCoord.getZ()) {
|
||||
minZ = position.getZ();
|
||||
}
|
||||
if (position.getZ() > maximumCoord.getZ()) {
|
||||
maxZ = position.getZ();
|
||||
}
|
||||
minimumCoord = new BlockPos(minX, minY, minZ);
|
||||
maximumCoord = new BlockPos(maxX, maxY, maxZ);
|
||||
}
|
||||
return Pair.of(minimumCoord, maximumCoord);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldRenderLast(RenderWorldLastEvent event){
|
||||
try{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer buffer = tessellator.getBuffer();
|
||||
float partialTicks = event.getPartialTicks();
|
||||
EntityPlayer entityplayer = Minecraft.getMinecraft().thePlayer;
|
||||
double d0 = entityplayer.lastTickPosX + (entityplayer.posX - entityplayer.lastTickPosX) * partialTicks;
|
||||
double d1 = entityplayer.lastTickPosY + (entityplayer.posY - entityplayer.lastTickPosY) * partialTicks;
|
||||
double d2 = entityplayer.lastTickPosZ + (entityplayer.posZ - entityplayer.lastTickPosZ) * partialTicks;
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.glLineWidth(5.0F);
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
List<IClimateRegion> regions = ForestryAPI.climateManager.getRegions().get(Integer.valueOf(world.provider.getDimension()));
|
||||
for(IClimateRegion region : regions){
|
||||
if(region != null){
|
||||
Map<BlockPos, IClimatePosition> positions = region.getPositions();
|
||||
Pair<BlockPos, BlockPos> posPair = recalculateMinMaxCoords(positions.keySet());
|
||||
int deltaX = posPair.getRight().getX() - posPair.getLeft().getX();
|
||||
deltaX+=2;
|
||||
int deltaZ = posPair.getRight().getZ() - posPair.getLeft().getZ();
|
||||
deltaZ+=3;
|
||||
getClass();
|
||||
for(Entry<BlockPos, IClimatePosition> positionEntry : positions.entrySet()){
|
||||
BlockPos pos = positionEntry.getKey();
|
||||
if(pos != null && world.isBlockLoaded(pos)){
|
||||
IClimatePosition position = positionEntry.getValue();
|
||||
float red = 1.0F;
|
||||
float green = 1.0F;
|
||||
float blue = 1.0F;
|
||||
int offset = 0;
|
||||
if(position.getTemperature() >= 2){
|
||||
green = 0F;
|
||||
blue = 0F;
|
||||
}
|
||||
else if(position.getTemperature() > 1.75){
|
||||
green = 0.25F;
|
||||
blue = 0.25F;
|
||||
offset = 1;
|
||||
}
|
||||
else if(position.getTemperature() > 1.5){
|
||||
green = 0.5F;
|
||||
blue = 0.5F;
|
||||
offset = 2;
|
||||
}
|
||||
else if(position.getTemperature() > 1.25){
|
||||
green = 0.75F;
|
||||
blue = 0.75F;
|
||||
offset = 3;
|
||||
}
|
||||
else if(position.getTemperature() > 0.75){
|
||||
green = 0.25F;
|
||||
red = 0.25F;
|
||||
offset = 4;
|
||||
}
|
||||
else if(position.getTemperature() > 0.5){
|
||||
green = 0.5F;
|
||||
red = 0.5F;
|
||||
offset = 5;
|
||||
}
|
||||
else if(position.getTemperature() > 0.25){
|
||||
green = 0.75F;
|
||||
red = 0.75F;
|
||||
offset = 6;
|
||||
}
|
||||
event.getContext().drawSelectionBoundingBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX - 1 * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().renderFilledBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX - 1 * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().drawSelectionBoundingBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX + offset * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
event.getContext().renderFilledBox(Block.FULL_BLOCK_AABB.offset(pos.getX() -d0, pos.getY() -d1, pos.getZ() -d2).offset(new BlockPos(deltaX + offset * deltaX, 0, deltaZ)), red, green, blue, 0.35F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||
Integer dim = Integer.valueOf(event.world.provider.getDimension());
|
||||
World world = event.world;
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if(!serverTicks.containsKey(dim)){
|
||||
serverTicks.put(dim, 1);
|
||||
MinecraftServer server = world.getMinecraftServer();
|
||||
if(server != null){
|
||||
server.addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Integer dim = Integer.valueOf(event.world.provider.getDimension());
|
||||
if(!serverTicks.containsKey(dim)){
|
||||
serverTicks.put(dim, 1);
|
||||
}
|
||||
int ticks = serverTicks.get(dim);
|
||||
Map<Integer, List<IClimateRegion>> regions = ForestryAPI.climateManager.getRegions();
|
||||
if(regions != null && regions.containsKey(dim)){
|
||||
for(IClimateRegion region : regions.get(dim)){
|
||||
region.updateClimate(ticks);
|
||||
}
|
||||
}
|
||||
serverTicks.put(dim, ticks+1);
|
||||
}
|
||||
});
|
||||
}
|
||||
int ticks = serverTicks.get(dim);
|
||||
Map<Integer, List<IClimateRegion>> regions = ForestryAPI.climateManager.getRegions();
|
||||
if(regions != null && regions.containsKey(dim)){
|
||||
for(IClimateRegion region : regions.get(dim)){
|
||||
region.updateClimate(ticks);
|
||||
}
|
||||
}
|
||||
serverTicks.put(dim, ticks+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
IClimateRegion region = getRegionForPos(source.getWorldObj(), source.getCoordinates());
|
||||
if(region != null){
|
||||
if(!region.getSources().contains(source.getClimateSource())){
|
||||
if(region.getSources().contains(source.getClimateSource())){
|
||||
region.removeSource(source.getClimateSource());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,10 +114,11 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
|
||||
@Override
|
||||
public void updateClimate(int ticks) {
|
||||
boolean hasChange = false;;
|
||||
for(IClimateSource source : sources){
|
||||
if(source != null){
|
||||
if(ticks % source.getTicksForChange(this) == 0){
|
||||
source.changeClimate(ticks, this);
|
||||
hasChange |= source.changeClimate(ticks, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +126,7 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
for(Entry<BlockPos, IClimatePosition> position : positions.entrySet()){
|
||||
BlockPos pos = position.getKey();
|
||||
if(world.isBlockLoaded(pos)){
|
||||
updateSides(pos);
|
||||
hasChange |= updateSides(pos);
|
||||
|
||||
if(!controller.isAssembled()){
|
||||
IClimateControl climateControl = getControl(pos);
|
||||
@@ -134,61 +135,57 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
if(climatedInfo.getTemperature() != climateControl.getControlTemperature()){
|
||||
if(climatedInfo.getTemperature() > climateControl.getControlTemperature()){
|
||||
climatedInfo.addTemperature(-Math.min(0.01F, climatedInfo.getTemperature() - climateControl.getControlTemperature()));
|
||||
hasChange = true;
|
||||
}else{
|
||||
climatedInfo.addTemperature(Math.min(0.01F, climateControl.getControlTemperature() - climatedInfo.getTemperature()));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
if(climatedInfo.getHumidity() != climateControl.getControlHumidity()){
|
||||
if(climatedInfo.getHumidity() > climateControl.getControlHumidity()){
|
||||
climatedInfo.addHumidity(-Math.min(0.01F, climatedInfo.getHumidity() - climateControl.getControlHumidity()));
|
||||
hasChange = true;
|
||||
}else{
|
||||
climatedInfo.addHumidity(Math.min(0.01F, climateControl.getControlHumidity() - climatedInfo.getHumidity()));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateSides(BlockPos pos){
|
||||
IClimatePosition climatedInfo = positions.get(pos);
|
||||
IClimateControl climateControl = getControl(pos);
|
||||
boolean hasChange = false;
|
||||
if(climateControl.getControlTemperature() != temperature || climateControl.getControlHumidity() != humidity) {
|
||||
boolean updateTemp = climatedInfo.getTemperature() >= climateControl.getControlTemperature();
|
||||
boolean updateHum = climatedInfo.getHumidity() >= climateControl.getControlHumidity();
|
||||
if(updateTemp || updateHum){
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
IClimatePosition climatedInfoFace = positions.get(pos.offset(facing));
|
||||
if(climatedInfoFace != null){
|
||||
if(climatedInfo.getTemperature() > climatedInfoFace.getTemperature() + 0.01F){
|
||||
float change = Math.min(0.01F, climatedInfo.getTemperature() - climatedInfoFace.getTemperature());
|
||||
climatedInfo.addTemperature(-change);
|
||||
climatedInfoFace.addTemperature(change);
|
||||
updateTemp = climatedInfo.getTemperature() >= climateControl.getControlTemperature();
|
||||
hasChange = true;
|
||||
}
|
||||
if(climatedInfo.getHumidity() > climatedInfoFace.getHumidity() + 0.01F){
|
||||
float change = Math.min(0.01F, climatedInfo.getHumidity() - climatedInfoFace.getHumidity());
|
||||
climatedInfo.addHumidity(-change);
|
||||
climatedInfoFace.addHumidity(change);
|
||||
updateHum = climatedInfo.getTemperature() >= climateControl.getControlTemperature();
|
||||
hasChange = true;
|
||||
}
|
||||
if(!updateTemp && !updateHum){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hasChange){
|
||||
temperature = getExactTemperature();
|
||||
humidity = getExactHumidity();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean updateSides(BlockPos pos){
|
||||
IClimatePosition climatedInfo = positions.get(pos);
|
||||
IClimateControl climateControl = getControl(pos);
|
||||
boolean hasChange = false;
|
||||
if(climateControl.getControlTemperature() != temperature || climateControl.getControlHumidity() != humidity) {
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
IClimatePosition climatedInfoFace = positions.get(pos.offset(facing));
|
||||
if(climatedInfoFace != null){
|
||||
if(climatedInfo.getTemperature() > climatedInfoFace.getTemperature() + 0.01F){
|
||||
float change = Math.min(0.01F, climatedInfo.getTemperature() - climatedInfoFace.getTemperature());
|
||||
climatedInfo.addTemperature(-change);
|
||||
climatedInfoFace.addTemperature(change);
|
||||
hasChange = true;
|
||||
}
|
||||
if(climatedInfo.getHumidity() > climatedInfoFace.getHumidity() + 0.01F){
|
||||
float change = Math.min(0.01F, climatedInfo.getHumidity() - climatedInfoFace.getHumidity());
|
||||
climatedInfo.addHumidity(-change);
|
||||
climatedInfoFace.addHumidity(change);
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasChange;
|
||||
}
|
||||
|
||||
protected IClimateControl getControl(BlockPos pos){
|
||||
if(world.isBlockLoaded(pos)){
|
||||
if(!controller.isAssembled()){
|
||||
@@ -246,7 +243,7 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
return positions;
|
||||
}
|
||||
|
||||
public void addPosition(BlockPos pos, float temperature, float humidity){
|
||||
public synchronized void addPosition(BlockPos pos, float temperature, float humidity){
|
||||
IClimatePosition otherPosition = positions.get(pos);
|
||||
if(otherPosition != null){
|
||||
otherPosition.setHumidity(humidity);
|
||||
@@ -257,14 +254,14 @@ public class ClimateRoom implements IClimateRegion, IStreamable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSource(IClimateSource source) {
|
||||
public synchronized void addSource(IClimateSource source) {
|
||||
if(!sources.contains(source)){
|
||||
sources.add(source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSource(IClimateSource source) {
|
||||
public synchronized void removeSource(IClimateSource source) {
|
||||
if(sources.contains(source)){
|
||||
sources.remove(source);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ public abstract class ClimateSource<P extends IClimateSourceProvider> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeClimate(int tickCount, IClimateRegion region) {
|
||||
public boolean changeClimate(int tickCount, IClimateRegion region) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ public class Config {
|
||||
|
||||
public static final String CATEGORY_COMMON = "common";
|
||||
public static final String CATEGORY_FLUIDS = "fluids";
|
||||
public static final String CATEGORY_FARM = "farm";
|
||||
|
||||
public static LocalizedConfiguration configCommon;
|
||||
public static LocalizedConfiguration configFluid;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GameMode implements IGameMode {
|
||||
private static final float ENERGY_DEMAND_MODIFIER = 1.0f;
|
||||
private static final float FUEL_MODIFIER = 1.0f;
|
||||
|
||||
private static final int FARM_FERTILIZER_VALUE = 2000;
|
||||
private static final int FARM_FERTILIZER_MODIFIER = 4;
|
||||
|
||||
private static final int recipeFertilizerOutputApatite = 8;
|
||||
private static final int recipeFertilizerOutputAsh = 16;
|
||||
@@ -75,7 +75,7 @@ public class GameMode implements IGameMode {
|
||||
initSettingFloat(config, "energy", "demand.modifier", ENERGY_DEMAND_MODIFIER);
|
||||
initSettingBoolean(config, "energy", "engine.clockwork", true);
|
||||
|
||||
initSettingInt(config, "farms", "fertilizer.value", FARM_FERTILIZER_VALUE);
|
||||
initSettingInt(config, "farms", "fertilizer.modifier", FARM_FERTILIZER_MODIFIER);
|
||||
|
||||
initSettingFloat(config, "fuel.ethanol", "generator", FUEL_MODIFIER);
|
||||
initSettingFloat(config, "fuel.ethanol", "combustion", FUEL_MODIFIER);
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.entities;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public abstract class EntitySelector<T extends Entity> implements Predicate<T> {
|
||||
private final Class<T> entityClass;
|
||||
|
||||
protected EntitySelector(Class<T> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
|
||||
public Class<T> getEntityClass() {
|
||||
return entityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Entity entity) {
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
T castEntity = entityClass.cast(entity);
|
||||
return isEntityApplicableTyped(castEntity);
|
||||
}
|
||||
|
||||
protected abstract boolean isEntityApplicableTyped(T entity);
|
||||
}
|
||||
@@ -5,16 +5,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.errors;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.render.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public enum EnumErrorCode implements IErrorState {
|
||||
|
||||
@@ -112,7 +110,8 @@ public enum EnumErrorCode implements IErrorState {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerSprite() {
|
||||
texture = TextureManager.registerSprite(new ResourceLocation(Constants.MOD_ID, "gui/errors/" + iconName));
|
||||
ResourceLocation location = new ResourceLocation(Constants.MOD_ID, "gui/errors/" + iconName);
|
||||
texture = TextureManager.getInstance().registerGuiSprite(location);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.fluids;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -35,9 +38,12 @@ public final class FluidHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canAcceptFluid(World world, BlockPos pos, EnumFacing facing, FluidStack fluid) {
|
||||
public static boolean canAcceptFluid(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, @Nonnull FluidStack fluid) {
|
||||
IFluidHandler capability = FluidUtil.getFluidHandler(world, pos, facing);
|
||||
if (capability != null) {
|
||||
if(capability.getTankProperties() == null){
|
||||
throw new NullPointerException("The fluid handler " + capability.toString() + " returns null in the method getTankProperties, this is not allowed, please report that to the author of the mod from that the handler is.");
|
||||
}
|
||||
for (IFluidTankProperties tankProperties : capability.getTankProperties()) {
|
||||
if (tankProperties.canFillFluidType(fluid)) {
|
||||
return true;
|
||||
@@ -48,10 +54,14 @@ public final class FluidHelper {
|
||||
}
|
||||
|
||||
public enum FillStatus {
|
||||
SUCCESS, INVALID_INPUT, NO_FLUID, NO_SPACE
|
||||
SUCCESS, INVALID_INPUT, NO_FLUID, NO_SPACE, NO_SPACE_FLUID
|
||||
}
|
||||
|
||||
|
||||
public static FillStatus fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean doFill) {
|
||||
return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, getEmptyContainer(inv.getStackInSlot(inputSlot)), doFill);
|
||||
}
|
||||
|
||||
public static FillStatus fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, ItemStack emptyStack, boolean doFill) {
|
||||
if (fluidToFill == null) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
@@ -65,13 +75,19 @@ public final class FluidHelper {
|
||||
ItemStack filled = input.copy();
|
||||
filled.stackSize = 1;
|
||||
|
||||
if(emptyStack == null){
|
||||
emptyStack = filled;
|
||||
}
|
||||
|
||||
IFluidHandler fluidFilledHandler = FluidUtil.getFluidHandler(filled);
|
||||
if (fluidFilledHandler == null) {
|
||||
IFluidHandler fluidEmptyHandler = FluidUtil.getFluidHandler(emptyStack);
|
||||
if (fluidFilledHandler == null || emptyStack != null && fluidEmptyHandler == null) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
|
||||
int containerEmptyCapacity = fluidEmptyHandler.fill(new FluidStack(fluidToFill, Integer.MAX_VALUE), false);
|
||||
int containerCapacity = fluidFilledHandler.fill(new FluidStack(fluidToFill, Integer.MAX_VALUE), false);
|
||||
if (containerCapacity <= 0) {
|
||||
if (containerCapacity <= 0 && containerEmptyCapacity <= 0) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
|
||||
@@ -89,7 +105,7 @@ public final class FluidHelper {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
|
||||
boolean moveToOutput = fluidInContainer.amount >= containerCapacity;
|
||||
boolean moveToOutput = fluidInContainer.amount >= containerEmptyCapacity;
|
||||
if (moveToOutput) {
|
||||
if (output != null && (output.stackSize >= output.getMaxStackSize() || !InventoryUtil.isItemEqual(filled, output))) {
|
||||
return FillStatus.NO_SPACE;
|
||||
@@ -109,14 +125,14 @@ public final class FluidHelper {
|
||||
output.stackSize++;
|
||||
}
|
||||
inv.decrStackSize(inputSlot, 1);
|
||||
} else {
|
||||
}else{
|
||||
inv.setInventorySlotContents(inputSlot, filled);
|
||||
}
|
||||
}
|
||||
|
||||
return FillStatus.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot) {
|
||||
ItemStack input = inv.getStackInSlot(inputSlot);
|
||||
if (input == null) {
|
||||
@@ -130,10 +146,11 @@ public final class FluidHelper {
|
||||
|
||||
if (input.stackSize == 1 || drainedItemSimulated.stackSize == 0) {
|
||||
ItemStack drainedItem = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, true);
|
||||
|
||||
if (drainedItem != null) {
|
||||
if (drainedItem.stackSize > 0) {
|
||||
if(drainedItem.stackSize > 0){
|
||||
inv.setInventorySlotContents(inputSlot, drainedItem);
|
||||
} else {
|
||||
}else {
|
||||
inv.decrStackSize(inputSlot, 1);
|
||||
}
|
||||
return true;
|
||||
@@ -143,6 +160,81 @@ public final class FluidHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static FillStatus drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, boolean doDrain) {
|
||||
ItemStack input = inv.getStackInSlot(inputSlot);
|
||||
if (input == null) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
ItemStack outputStack = inv.getStackInSlot(outputSlot);
|
||||
|
||||
ItemStack drainedItemSimulated = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, false);
|
||||
if (drainedItemSimulated == null) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
|
||||
if (outputStack == null || drainedItemSimulated.stackSize == 0 || ItemStackUtil.isIdenticalItem(outputStack, drainedItemSimulated) && outputStack.stackSize + drainedItemSimulated.stackSize < outputStack.getMaxStackSize()) {
|
||||
if(doDrain){
|
||||
ItemStack drainedItem = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, true);
|
||||
|
||||
if (drainedItem != null) {
|
||||
if(drainedItem.stackSize > 0){
|
||||
ItemStack newStack = drainedItem.copy();
|
||||
if(outputStack != null){
|
||||
newStack.stackSize+=outputStack.stackSize;
|
||||
}
|
||||
if (isFillableContainerAndEmpty(newStack)) {
|
||||
inv.setInventorySlotContents(outputSlot, newStack);
|
||||
inv.decrStackSize(inputSlot, 1);
|
||||
}
|
||||
}else {
|
||||
inv.decrStackSize(inputSlot, 1);
|
||||
}
|
||||
return FillStatus.SUCCESS;
|
||||
}
|
||||
}
|
||||
return FillStatus.SUCCESS;
|
||||
}
|
||||
|
||||
return FillStatus.NO_SPACE;
|
||||
}
|
||||
|
||||
public static boolean isFillableContainerAndEmpty(ItemStack container) {
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
|
||||
if (fluidHandler == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties();
|
||||
for (IFluidTankProperties properties : tankProperties) {
|
||||
if (properties.canFill() && properties.getCapacity() > 0) {
|
||||
FluidStack contents = properties.getContents();
|
||||
if (contents == null) {
|
||||
return true;
|
||||
} else if (contents.amount > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getEmptyContainer(ItemStack container){
|
||||
if(container == null){
|
||||
return null;
|
||||
}
|
||||
ItemStack empty = container.copy();
|
||||
empty.stackSize = 1;
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(empty);
|
||||
if (fluidHandler == null) {
|
||||
return null;
|
||||
}
|
||||
if(fluidHandler.drain(Integer.MAX_VALUE, true) != null){
|
||||
return empty;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isFillableContainerWithRoom(ItemStack container) {
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
|
||||
if (fluidHandler == null) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -260,16 +261,19 @@ public enum Fluids {
|
||||
}
|
||||
|
||||
public boolean flowTextureExists() {
|
||||
if (FMLCommonHandler.instance().getSide() == Side.SERVER) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
ResourceLocation resourceLocation = new ForestryResource("blocks/liquid/" + getTag() + "_flow");
|
||||
IResourceManager resourceManager = Proxies.common.getClientInstance().getResourceManager();
|
||||
return resourceManager.getResource(resourceLocation) != null;
|
||||
Minecraft minecraft = Proxies.common.getClientInstance();
|
||||
if(minecraft != null){
|
||||
IResourceManager resourceManager = minecraft.getResourceManager();
|
||||
return resourceManager.getResource(resourceLocation) != null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ResourceLocation[] getResources() {
|
||||
|
||||
@@ -298,6 +298,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
return tanks.get(tankIndex).getInfo();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FluidStack getFluid(int tankIndex) {
|
||||
return tanks.get(tankIndex).getFluid();
|
||||
}
|
||||
|
||||
@@ -120,12 +120,12 @@ public abstract class Genome implements IGenome {
|
||||
}
|
||||
|
||||
NBTTagCompound genomeNBT = nbtTagCompound.getCompoundTag("Genome");
|
||||
if (genomeNBT == null) {
|
||||
if (genomeNBT.hasNoTags()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
|
||||
if (chromosomesNBT == null) {
|
||||
if (chromosomesNBT.hasNoTags()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public abstract class Genome implements IGenome {
|
||||
}
|
||||
|
||||
NBTTagCompound genome = nbtTagCompound.getCompoundTag("Genome");
|
||||
if (genome == null) {
|
||||
if (genome.hasNoTags()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -212,16 +212,19 @@ public abstract class Genome implements IGenome {
|
||||
|
||||
// / INFORMATION RETRIEVAL
|
||||
@Override
|
||||
@Nonnull
|
||||
public IChromosome[] getChromosomes() {
|
||||
return Arrays.copyOf(chromosomes, chromosomes.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IAllele getActiveAllele(IChromosomeType chromosomeType) {
|
||||
return chromosomes[chromosomeType.ordinal()].getActiveAllele();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IAllele getInactiveAllele(IChromosomeType chromosomeType) {
|
||||
return chromosomes[chromosomeType.ordinal()].getInactiveAllele();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import forestry.core.gui.slots.SlotForestry;
|
||||
import forestry.core.gui.slots.SlotLocked;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
|
||||
import invtweaks.api.container.ContainerSection;
|
||||
@@ -100,8 +99,6 @@ public abstract class ContainerForestry extends Container {
|
||||
for (IContainerListener listener : listeners) {
|
||||
if (listener instanceof EntityPlayer) {
|
||||
Proxies.net.sendToPlayer(packet, (EntityPlayer) listener);
|
||||
} else {
|
||||
Log.error("Unknown listener type: {}", listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.gui;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -23,6 +24,8 @@ import forestry.core.gui.ledgers.HintLedger;
|
||||
import forestry.core.gui.ledgers.LedgerManager;
|
||||
import forestry.core.gui.ledgers.OwnerLedger;
|
||||
import forestry.core.gui.ledgers.PowerLedger;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -40,6 +43,8 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public abstract class GuiForestry<C extends Container, I extends IInventory> extends GuiContainer {
|
||||
protected final I inventory;
|
||||
@@ -152,11 +157,25 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
super.mouseClickMove(mouseX, mouseY, mouseButton, time);
|
||||
}
|
||||
|
||||
protected Slot getSlotAtPosition(int par1, int par2) {
|
||||
@Nullable
|
||||
public FluidStack getFluidStackAtPosition(int mouseX, int mouseY) {
|
||||
for (Widget widget : widgetManager.getWidgets()) {
|
||||
if (widget instanceof TankWidget && widget.isMouseOver(mouseX - guiLeft, mouseY - guiTop)) {
|
||||
TankWidget tankWidget = (TankWidget) widget;
|
||||
IFluidTank tank = tankWidget.getTank();
|
||||
if (tank != null) {
|
||||
return tank.getFluid();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Slot getSlotAtPosition(int mouseX, int mouseY) {
|
||||
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) {
|
||||
Slot slot = this.inventorySlots.inventorySlots.get(k);
|
||||
|
||||
if (isMouseOverSlot(slot, par1, par2)) {
|
||||
if (isMouseOverSlot(slot, mouseX, mouseY)) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
@@ -164,8 +183,8 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isMouseOverSlot(Slot par1Slot, int par2, int par3) {
|
||||
return isPointInRegion(par1Slot.xDisplayPosition, par1Slot.yDisplayPosition, 16, 16, par2, par3);
|
||||
private boolean isMouseOverSlot(Slot par1Slot, int mouseX, int mouseY) {
|
||||
return isPointInRegion(par1Slot.xDisplayPosition, par1Slot.yDisplayPosition, 16, 16, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,7 @@ import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.apiculture.genetics.BeeRoot;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.genetics.mutations.EnumMutateChance;
|
||||
import forestry.core.gui.buttons.GuiBetterButton;
|
||||
|
||||
@@ -13,18 +13,17 @@ package forestry.core.gui.ledgers;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.SessionVars;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ForestryResource;
|
||||
import forestry.core.render.TextureManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Side ledger for guis
|
||||
@@ -214,9 +213,13 @@ public abstract class Ledger {
|
||||
}
|
||||
|
||||
protected void drawSprite(TextureAtlasSprite sprite, int x, int y) {
|
||||
drawSprite(TextureManager.getInstance().getGuiTextureMap(), sprite, x, y);
|
||||
}
|
||||
|
||||
protected void drawSprite(ResourceLocation textureMap, TextureAtlasSprite sprite, int x, int y) {
|
||||
if (sprite != null) {
|
||||
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F);
|
||||
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
Proxies.render.bindTexture(textureMap);
|
||||
manager.gui.drawTexturedModalRect(x, y, sprite, 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui.slots;
|
||||
|
||||
import forestry.core.gui.tooltips.IToolTipProvider;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.render.TextureManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gui.tooltips.IToolTipProvider;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class SlotForestry extends Slot implements IToolTipProvider {
|
||||
|
||||
@@ -31,6 +33,9 @@ public class SlotForestry extends Slot implements IToolTipProvider {
|
||||
if (inventory == null) {
|
||||
throw new IllegalArgumentException("Inventory must not be null");
|
||||
}
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
setBackgroundLocation(TextureManager.getInstance().getGuiTextureMap());
|
||||
}
|
||||
this.stackLimit = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui.widgets;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gui.GuiUtil;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
@@ -23,6 +17,10 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.tiles.EscritoireGame;
|
||||
import forestry.core.tiles.EscritoireGameToken;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GameTokenWidget extends Widget {
|
||||
private final ItemStack HIDDEN_TOKEN = new ItemStack(Items.BOOK);
|
||||
@@ -70,8 +68,9 @@ public class GameTokenWidget extends Widget {
|
||||
|
||||
GlStateManager.disableDepth();
|
||||
for (String ident : getToken().getOverlayIcons()) {
|
||||
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
TextureAtlasSprite icon = TextureManager.getInstance().getDefault(ident);
|
||||
TextureManager textureManager = TextureManager.getInstance();
|
||||
Proxies.render.bindTexture(textureManager.getGuiTextureMap());
|
||||
TextureAtlasSprite icon = textureManager.getDefault(ident);
|
||||
manager.gui.drawTexturedModalRect(startX + xPos + 3, startY + yPos + 3, icon, 16, 16);
|
||||
}
|
||||
GlStateManager.enableDepth();
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui.widgets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.gui.IContainerLiquidTanks;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.farming.gui.ContainerFarm;
|
||||
import forestry.greenhouse.gui.ContainerGreenhouse;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -22,19 +31,10 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.gui.IContainerLiquidTanks;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.farming.gui.ContainerFarm;
|
||||
import forestry.greenhouse.gui.ContainerGreenhouse;
|
||||
|
||||
/**
|
||||
* Slot for liquid tanks
|
||||
*/
|
||||
@@ -57,6 +57,7 @@ public class TankWidget extends Widget {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IFluidTank getTank() {
|
||||
Container container = manager.gui.inventorySlots;
|
||||
if (container instanceof IContainerLiquidTanks) {
|
||||
|
||||
@@ -98,13 +98,19 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!base.hasTagCompound() || !comparison.hasTagCompound()) {
|
||||
NBTTagCompound baseTagCompound = base.getTagCompound();
|
||||
NBTTagCompound comparisonTagCompound = comparison.getTagCompound();
|
||||
if (baseTagCompound == null || comparisonTagCompound == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String baseUID = base.getTagCompound().getString(KEY_UID);
|
||||
String comparisonUID = comparison.getTagCompound().getString(KEY_UID);
|
||||
return baseUID != null && comparisonUID != null && baseUID.equals(comparisonUID);
|
||||
if (!baseTagCompound.hasKey(KEY_UID) || !comparisonTagCompound.hasKey(KEY_UID)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int baseUID = baseTagCompound.getInteger(KEY_UID);
|
||||
int comparisonUID = comparisonTagCompound.getInteger(KEY_UID);
|
||||
return baseUID == comparisonUID;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
@@ -37,6 +37,9 @@ public abstract class ModelBlockCached<B extends Block, K> extends ModelBlockDef
|
||||
|
||||
@Override
|
||||
protected IBakedModel getModel(@Nonnull IBlockState state) {
|
||||
if(state == null){
|
||||
return null;
|
||||
}
|
||||
K key = getWorldKey(state);
|
||||
if (key == null) {
|
||||
return null;
|
||||
|
||||
@@ -20,6 +20,7 @@ import forestry.api.core.IModelBakerModel;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
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.Minecraft;
|
||||
@@ -101,6 +102,9 @@ public abstract class ModelBlockDefault<B extends Block, K> implements IBakedMod
|
||||
}
|
||||
|
||||
protected IBakedModel getModel(ItemStack stack, World world) {
|
||||
if(stack == null){
|
||||
return null;
|
||||
}
|
||||
return bakeModel(stack, world, getInventoryKey(stack));
|
||||
}
|
||||
|
||||
@@ -187,6 +191,9 @@ public abstract class ModelBlockDefault<B extends Block, K> implements IBakedMod
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
if(world == null){
|
||||
world = Proxies.common.getRenderWorld();
|
||||
}
|
||||
return getModel(stack, world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,159 +10,89 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.models;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
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;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ItemModelMesherForge;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.IPerspectiveAwareModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.storage.PluginStorage;
|
||||
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCrate extends BlankModel {
|
||||
|
||||
private static final Cache<String, IBakedModel> cache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).build();
|
||||
private static ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> itemTransforms;
|
||||
private static Map<String, IBakedModel> cache = new HashMap<String, IBakedModel>();
|
||||
private static final String CUSTOM_CRATES = "forestry:item/crates/";
|
||||
|
||||
private static IModel crateModel;
|
||||
private static ModelBlock MODEL_GENERATED;
|
||||
private static ModelBlock MODEL_ENTITY;
|
||||
|
||||
/**
|
||||
* Init the model with datas from the ModelBakeEvent.
|
||||
*/
|
||||
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);
|
||||
MODEL_ENTITY = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.getModelLoader(), 18);
|
||||
} catch (Exception e) {
|
||||
Log.error("Failed to init the crate model.", e);
|
||||
}
|
||||
ModelCrate.cache.invalidateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The item model ResourceLocation from a ModelResourceLocation
|
||||
*/
|
||||
private ResourceLocation getItemLocation(ModelResourceLocation modelResource) {
|
||||
ResourceLocation resourcelocation = new ResourceLocation(modelResource.toString().replaceAll("#.*", ""));
|
||||
return new ResourceLocation(resourcelocation.getResourceDomain(), "item/" + resourcelocation.getResourcePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return true, when the model a item model is.
|
||||
*/
|
||||
private boolean hasItemModel(ResourceLocation location) {
|
||||
try {
|
||||
ModelBlock modelBlock = loadModel(location);
|
||||
if (modelBlock == null) {
|
||||
return false;
|
||||
} else {
|
||||
return modelBlock.getRootModel() == MODEL_GENERATED;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
cache.clear();
|
||||
itemTransforms = getMap(new ResourceLocation("minecraft:models/item/generated"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Load a model from the location.
|
||||
*/
|
||||
private ModelBlock loadModel(ResourceLocation location) throws IOException{
|
||||
Reader reader = null;
|
||||
IResource iresource = null;
|
||||
ModelBlock model;
|
||||
|
||||
try{
|
||||
String s = location.getResourcePath();
|
||||
|
||||
if (!"builtin/generated".equals(s)){
|
||||
if ("builtin/entity".equals(s)){
|
||||
model = MODEL_ENTITY;
|
||||
return model;
|
||||
}
|
||||
|
||||
if (s.startsWith("builtin/")) {
|
||||
String s1 = s.substring("builtin/".length());
|
||||
if (s1.equals("missing")) {
|
||||
reader = new StringReader("{ \"textures\": { \"particle\": \"missingno\", \"missingno\": \"missingno\"}, \"elements\": [ { \"from\": [ 0, 0, 0 ], \"to\": [ 16, 16, 16 ], \"faces\": { \"down\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"down\", \"texture\": \"#missingno\" }, \"up\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"up\", \"texture\": \"#missingno\" }, \"north\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"north\", \"texture\": \"#missingno\" }, \"south\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"south\", \"texture\": \"#missingno\" }, \"west\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"west\", \"texture\": \"#missingno\" }, \"east\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"east\", \"texture\": \"#missingno\" } }}]}");
|
||||
} else {
|
||||
throw new FileNotFoundException(location.toString());
|
||||
}
|
||||
}else{
|
||||
iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.getModelLocation(location));
|
||||
reader = new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8);
|
||||
}
|
||||
|
||||
model = ModelBlock.deserialize(reader);
|
||||
model.name = location.toString();
|
||||
if (model != null && model.getParentLocation() != null) {
|
||||
if (model.getParentLocation().getResourcePath().equals("builtin/generated")) {
|
||||
model.parent = MODEL_GENERATED;
|
||||
} else {
|
||||
try {
|
||||
model.parent = loadModel(model.getParentLocation());
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to load model.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
model = MODEL_GENERATED;
|
||||
}
|
||||
finally{
|
||||
IOUtils.closeQuietly(reader);
|
||||
IOUtils.closeQuietly(iresource);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private ResourceLocation getModelLocation(ResourceLocation resourceLocation) {
|
||||
return new ResourceLocation(resourceLocation.getResourceDomain(), "models/" + resourceLocation.getResourcePath() + ".json");
|
||||
public static ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> getMap(ResourceLocation par1)
|
||||
{
|
||||
return IPerspectiveAwareModel.MapWrapper.getTransforms(getTransformFromJson(par1));
|
||||
}
|
||||
|
||||
private static Reader getReaderForResource(ResourceLocation location) throws IOException
|
||||
{
|
||||
ResourceLocation file = new ResourceLocation(location.getResourceDomain(), location.getResourcePath() + ".json");
|
||||
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(file);
|
||||
return new BufferedReader(new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8));
|
||||
}
|
||||
|
||||
private static ItemCameraTransforms getTransformFromJson(ResourceLocation par1)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ModelBlock.deserialize(getReaderForResource(par1)).getAllTransforms();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The model from the item of the stack.
|
||||
@@ -176,50 +106,16 @@ public class ModelCrate extends BlankModel {
|
||||
return new CrateOverrideList();
|
||||
}
|
||||
|
||||
private static IModel getCustomContentModel(ItemCrated crateItem){
|
||||
ItemStack contained = crateItem.getContained();
|
||||
if(contained != null){
|
||||
try {
|
||||
return ModelLoaderRegistry.getModel(getCustomContentModelLocation(crateItem));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ResourceLocation getCustomContentModelLocation(ItemCrated crateItem){
|
||||
String containedName = crateItem.getRegistryName().getResourcePath().replace("crated.", "");
|
||||
return new ResourceLocation(CUSTOM_CRATES + containedName);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Bake the crate model.
|
||||
*/
|
||||
private List<IBakedModel> bakeModel(ItemCrated crateItem, IBakedModel crateModel) {
|
||||
private List<IBakedModel> bakeModel(ItemCrated crateItem) {
|
||||
List<IBakedModel> models = new ArrayList<>();
|
||||
|
||||
IBakedModel containedModel = getModel(crateItem.getContained());
|
||||
IModel customContentModel = getCustomContentModel(crateItem);
|
||||
|
||||
IdentityHashMap<Item, TIntObjectHashMap<ModelResourceLocation>> modelResourceLocations = ObfuscationReflectionHelper.getPrivateValue(ItemModelMesherForge.class, (ItemModelMesherForge) Minecraft.getMinecraft().getRenderItem().getItemModelMesher(), 0);
|
||||
|
||||
ModelResourceLocation modelResource = modelResourceLocations.get(crateItem.getContained().getItem()).get(crateItem.getContained().getItemDamage());
|
||||
ResourceLocation location = getItemLocation(modelResource);
|
||||
|
||||
models.add(crateModel);
|
||||
|
||||
if(customContentModel != null){
|
||||
containedModel = customContentModel.bake(ModelManager.getInstance().DEFAULT_ITEM, DefaultVertexFormats.ITEM, new DefaultTextureGetter());
|
||||
location = getCustomContentModelLocation(crateItem);
|
||||
}
|
||||
|
||||
if (hasItemModel(location)) {
|
||||
ItemStack contained = crateItem.getContained();
|
||||
if (contained != null) {
|
||||
IBakedModel containedModel = getModel(contained);
|
||||
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, 0.0625F, 0.5F));
|
||||
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, -0.0625F, 0.5F));
|
||||
} else {
|
||||
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, 0, 0.5F));
|
||||
}
|
||||
return models;
|
||||
}
|
||||
@@ -227,7 +123,7 @@ public class ModelCrate extends BlankModel {
|
||||
private class CrateOverrideList extends ItemOverrideList{
|
||||
|
||||
public CrateOverrideList() {
|
||||
super(Collections.emptyList());
|
||||
super(new ArrayList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,37 +133,76 @@ 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.getIfPresent(crateUID) == null) {
|
||||
IBakedModel model = cache.get(crateUID);
|
||||
if(model == null)
|
||||
{
|
||||
//Fastest list with a unknown quad size
|
||||
List<BakedQuad> list = new LinkedList<BakedQuad>();
|
||||
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)) {
|
||||
ObfuscationReflectionHelper.setPrivateValue(BakedQuad.class, quad, 100, 1);
|
||||
for(BakedQuad quad : ForgeHooksClient.handleCameraTransforms(baseBaked, TransformType.GROUND, false).getQuads(null, null, 0L))
|
||||
{
|
||||
list.add(new BakedQuad(quad.getVertexData(), 100, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()));
|
||||
}
|
||||
|
||||
cache.put(crateUID, new IPerspectiveAwareModel.MapWrapper(new CrateBakedModel( bakeModel(crated, baseBaked)), ModelManager.getInstance().DEFAULT_ITEM));
|
||||
List<IBakedModel> textures = bakeModel(crated);
|
||||
for(IBakedModel bakybake : textures)
|
||||
{
|
||||
list.addAll(ForgeHooksClient.handleCameraTransforms(bakybake, TransformType.GROUND, false).getQuads(null, null, 0L));
|
||||
}
|
||||
model = new BakedCrateModel(list);
|
||||
cache.put(crateUID, model);
|
||||
}
|
||||
return cache.getIfPresent(crateUID);
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class CrateBakedModel extends BlankModel{
|
||||
|
||||
public final List<IBakedModel> models;
|
||||
public static class BakedCrateModel extends BlankModel implements IPerspectiveAwareModel
|
||||
{
|
||||
BakedCrateModel other;
|
||||
boolean gui;
|
||||
List<BakedQuad> quads = new ArrayList<BakedQuad>();
|
||||
private List<BakedQuad> emptyList = new ArrayList<BakedQuad>();
|
||||
|
||||
public CrateBakedModel(List<IBakedModel> models) {
|
||||
this.models = models;
|
||||
public BakedCrateModel(BakedCrateModel noneGui)
|
||||
{
|
||||
gui = true;
|
||||
other = noneGui;
|
||||
for(BakedQuad quad : other.quads)
|
||||
{
|
||||
if(quad.getFace() == EnumFacing.SOUTH)
|
||||
{
|
||||
quads.add(quad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BakedCrateModel(List<BakedQuad> data)
|
||||
{
|
||||
quads.addAll(data);
|
||||
gui = false;
|
||||
other = new BakedCrateModel(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
for(IBakedModel bakedModel : models){
|
||||
quads.addAll(bakedModel.getQuads(null, side, rand++));
|
||||
}
|
||||
return quads;
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
{
|
||||
return side == null ? quads : emptyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
|
||||
{
|
||||
Pair<? extends IBakedModel, Matrix4f> pair = IPerspectiveAwareModel.MapWrapper.handlePerspective(this, itemTransforms, cameraTransformType);
|
||||
if(cameraTransformType == TransformType.GUI && !gui && pair.getRight() == null)
|
||||
{
|
||||
return Pair.of(other, null);
|
||||
}
|
||||
else if(cameraTransformType != TransformType.GUI && gui)
|
||||
{
|
||||
return Pair.of(other, pair.getRight());
|
||||
}
|
||||
return pair;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -315,7 +315,7 @@ public class MultiblockWorldRegistry {
|
||||
if (worldObj.getChunkProvider().getLoadedChunk(worldLocation.getX() >> 4, worldLocation.getZ() >> 4) == null) {
|
||||
// Part goes into the waiting-for-chunk-load list
|
||||
Set<IMultiblockComponent> partSet;
|
||||
long chunkHash = ChunkPos.chunkXZ2Int(worldLocation.getX() >> 4, worldLocation.getZ() >> 4);
|
||||
long chunkHash = ChunkPos.asLong(worldLocation.getX() >> 4, worldLocation.getZ() >> 4);
|
||||
synchronized (partsAwaitingChunkLoadMutex) {
|
||||
if (!partsAwaitingChunkLoad.containsKey(chunkHash)) {
|
||||
partSet = new HashSet<>();
|
||||
@@ -340,7 +340,7 @@ public class MultiblockWorldRegistry {
|
||||
public void onPartRemovedFromWorld(IMultiblockComponent part) {
|
||||
BlockPos coord = part.getCoordinates();
|
||||
if (coord != null) {
|
||||
long hash = ChunkPos.chunkXZ2Int(coord.getX() >> 4, coord.getZ() >> 4);
|
||||
long hash = ChunkPos.asLong(coord.getX() >> 4, coord.getZ() >> 4);
|
||||
|
||||
if (partsAwaitingChunkLoad.containsKey(hash)) {
|
||||
synchronized (partsAwaitingChunkLoadMutex) {
|
||||
@@ -396,7 +396,7 @@ public class MultiblockWorldRegistry {
|
||||
* @param chunkZ Chunk Z coordinate (world coordate >> 4) of the chunk that was loaded
|
||||
*/
|
||||
public void onChunkLoaded(int chunkX, int chunkZ) {
|
||||
long chunkHash = ChunkPos.chunkXZ2Int(chunkX, chunkZ);
|
||||
long chunkHash = ChunkPos.asLong(chunkX, chunkZ);
|
||||
if (partsAwaitingChunkLoad.containsKey(chunkHash)) {
|
||||
synchronized (partsAwaitingChunkLoadMutex) {
|
||||
if (partsAwaitingChunkLoad.containsKey(chunkHash)) {
|
||||
|
||||
@@ -33,6 +33,9 @@ public enum PacketIdServer implements IPacketId {
|
||||
// Apiculture
|
||||
BEE_LOGIC_ACTIVE_ENTITY_REQUEST,
|
||||
|
||||
// Genetics
|
||||
GENOME_TRACKER_REQUEST,
|
||||
|
||||
// Mail
|
||||
LETTER_INFO_REQUEST,
|
||||
TRADING_ADDRESS_REQUEST,
|
||||
|
||||
@@ -16,6 +16,7 @@ import forestry.core.network.packets.PacketChipsetClick;
|
||||
import forestry.core.network.packets.PacketErrorUpdate;
|
||||
import forestry.core.network.packets.PacketErrorUpdateEntity;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.network.packets.PacketGenomeTrackerRequest;
|
||||
import forestry.core.network.packets.PacketGenomeTrackerSync;
|
||||
import forestry.core.network.packets.PacketGuiEnergy;
|
||||
import forestry.core.network.packets.PacketGuiLayoutSelect;
|
||||
@@ -53,5 +54,6 @@ public class PacketRegistryCore extends PacketRegistry {
|
||||
registerServerPacket(new PacketSolderingIronClick());
|
||||
registerServerPacket(new PacketCamouflageSelectServer());
|
||||
registerServerPacket(new PacketUpdateClimateControl());
|
||||
registerServerPacket(new PacketGenomeTrackerRequest());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package forestry.core.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleRegistry;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
public class PacketGenomeTrackerRequest extends ForestryPacket implements IForestryPacketServer {
|
||||
|
||||
@Override
|
||||
public PacketIdServer getPacketId() {
|
||||
return PacketIdServer.GENOME_TRACKER_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
IAlleleRegistry alleleRegistry = AlleleManager.alleleRegistry;
|
||||
Collection<ISpeciesRoot> speciesRoots = alleleRegistry.getSpeciesRoot().values();
|
||||
for (ISpeciesRoot speciesRoot : speciesRoots) {
|
||||
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.getEntityWorld(), player.getGameProfile());
|
||||
breedingTracker.synchToPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.proxy;
|
||||
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
|
||||
public class ProxyNetworkClient extends ProxyNetwork {
|
||||
|
||||
@Override
|
||||
public void sendToServer(IForestryPacketServer packet) {
|
||||
NetHandlerPlayClient netHandler = Proxies.common.getClientInstance().getConnection();
|
||||
if (netHandler != null) {
|
||||
netHandler.sendPacket(packet.getPacket());
|
||||
}
|
||||
Preconditions.checkNotNull(netHandler, "Tried to send packet before netHandler (client world) exists.");
|
||||
netHandler.sendPacket(packet.getPacket());
|
||||
}
|
||||
}
|
||||
@@ -10,39 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.proxy;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.animation.ITimeValue;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IHiveTile;
|
||||
@@ -66,12 +37,40 @@ import forestry.core.render.RenderEscritoire;
|
||||
import forestry.core.render.RenderMachine;
|
||||
import forestry.core.render.RenderMill;
|
||||
import forestry.core.render.RenderNaturalistChest;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.render.TextureMapForestry;
|
||||
import forestry.core.tiles.TileAnalyzer;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
import forestry.core.tiles.TileMill;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
import forestry.core.utils.VectUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.animation.ITimeValue;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
|
||||
public class ProxyRenderClient extends ProxyRender {
|
||||
|
||||
@@ -85,6 +84,15 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initRendering() {
|
||||
TextureManager textureManager = TextureManager.getInstance();
|
||||
TextureMapForestry textureMap = textureManager.getTextureMap();
|
||||
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
minecraft.renderEngine.loadTickableTexture(TextureManager.getInstance().getGuiTextureMap(), textureMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntitySpecialRenderer<TileBase> getRenderDefaultMachine(String gfxBase) {
|
||||
if (gfxBase == null) {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ParticleHelper {
|
||||
if (block != state.getBlock()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
byte iterations = 4;
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
for (int j = 0; j < iterations; ++j) {
|
||||
|
||||
@@ -11,31 +11,27 @@
|
||||
package forestry.core.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextureManager implements ITextureManager {
|
||||
|
||||
public static final ResourceLocation LOCATION_FORESTRY_TEXTURE = new ResourceLocation(Constants.MOD_ID, "textures/atlas/gui");
|
||||
private static final TextureManager INSTANCE = new TextureManager();
|
||||
private static final Map<String, TextureAtlasSprite> defaultIcons = new HashMap<>();
|
||||
private final List<ISpriteRegister> spriteRegisters = new ArrayList<>();
|
||||
private final TextureMapForestry textureMap;
|
||||
|
||||
static {
|
||||
ForestryAPI.textureManager = INSTANCE;
|
||||
@@ -46,6 +42,11 @@ public class TextureManager implements ITextureManager {
|
||||
}
|
||||
|
||||
private TextureManager() {
|
||||
this.textureMap = new TextureMapForestry("textures");
|
||||
}
|
||||
|
||||
public TextureMapForestry getTextureMap() {
|
||||
return textureMap;
|
||||
}
|
||||
|
||||
public static void initDefaultSprites() {
|
||||
@@ -59,22 +60,36 @@ public class TextureManager implements ITextureManager {
|
||||
"slots/blocked", "slots/blocked_2", "slots/liquid", "slots/container", "slots/locked",
|
||||
"mail/carrier.player", "mail/carrier.trader"};
|
||||
for (String identifier : defaultIconNames) {
|
||||
ResourceLocation resourceLocation = new ResourceLocation(Constants.MOD_ID, "gui/" + identifier);
|
||||
TextureAtlasSprite icon = registerSprite(resourceLocation);
|
||||
defaultIcons.put(identifier, icon);
|
||||
ResourceLocation resourceLocation = getForestryGuiLocation(identifier);
|
||||
INSTANCE.registerGuiSprite(resourceLocation);
|
||||
}
|
||||
}
|
||||
|
||||
private static ResourceLocation getForestryGuiLocation(String identifier) {
|
||||
return new ResourceLocation(Constants.MOD_ID, "gui/" + identifier);
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite registerSprite(ResourceLocation location) {
|
||||
TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
return textureMap.registerSprite(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getDefault(String ident) {
|
||||
return defaultIcons.get(ident);
|
||||
public TextureAtlasSprite getDefault(String identifier) {
|
||||
ResourceLocation resourceLocation = getForestryGuiLocation(identifier);
|
||||
return getTextureMap().getAtlasSprite(resourceLocation.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGuiTextureMap() {
|
||||
return LOCATION_FORESTRY_TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite registerGuiSprite(ResourceLocation location) {
|
||||
return getTextureMap().registerSprite(location);
|
||||
}
|
||||
|
||||
public void registerBlock(Block block) {
|
||||
if (block instanceof ISpriteRegister) {
|
||||
spriteRegisters.add((ISpriteRegister) block);
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
package forestry.core.render;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import forestry.core.utils.Log;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.PngSizeInfo;
|
||||
import net.minecraft.client.renderer.texture.Stitcher;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.crash.ICrashReportDetail;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.ProgressManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextureMapForestry extends TextureMap {
|
||||
private boolean skipFirst = true;
|
||||
|
||||
public TextureMapForestry(String basePathIn) {
|
||||
super(basePathIn, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTexture(@Nonnull IResourceManager resourceManager) throws IOException {
|
||||
this.initMissingImage();
|
||||
this.deleteGlTexture();
|
||||
this.loadTextureAtlas(resourceManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTextureAtlas(@Nonnull IResourceManager resourceManager) {
|
||||
int i = Minecraft.getGLMaximumTextureSize();
|
||||
Stitcher stitcher = new Stitcher(i, i, 0, 0);
|
||||
this.mapUploadedSprites.clear();
|
||||
this.listAnimatedSprites.clear();
|
||||
|
||||
ProgressManager.ProgressBar bar = ProgressManager.push("Texture stitching", skipFirst ? 0 : this.mapRegisteredSprites.size());
|
||||
|
||||
if (!skipFirst) {
|
||||
for (Map.Entry<String, TextureAtlasSprite> entry : this.mapRegisteredSprites.entrySet()) {
|
||||
TextureAtlasSprite textureatlassprite = entry.getValue();
|
||||
ResourceLocation resourcelocation = this.getResourceLocation(textureatlassprite);
|
||||
bar.step(resourcelocation.getResourcePath());
|
||||
IResource iresource = null;
|
||||
|
||||
if (textureatlassprite.hasCustomLoader(resourceManager, resourcelocation)) {
|
||||
if (textureatlassprite.load(resourceManager, resourcelocation)) {
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
try {
|
||||
PngSizeInfo pngsizeinfo = PngSizeInfo.makeFromResource(resourceManager.getResource(resourcelocation));
|
||||
iresource = resourceManager.getResource(resourcelocation);
|
||||
boolean flag = iresource.getMetadata("animation") != null;
|
||||
textureatlassprite.loadSprite(pngsizeinfo, flag);
|
||||
} catch (RuntimeException runtimeexception) {
|
||||
FMLClientHandler.instance().trackBrokenTexture(resourcelocation, runtimeexception.getMessage());
|
||||
continue;
|
||||
} catch (IOException ioexception) {
|
||||
FMLClientHandler.instance().trackMissingTexture(resourcelocation);
|
||||
continue;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(iresource);
|
||||
}
|
||||
|
||||
stitcher.addSprite(textureatlassprite);
|
||||
}
|
||||
}
|
||||
|
||||
ProgressManager.pop(bar);
|
||||
|
||||
this.missingImage.generateMipmaps(0);
|
||||
stitcher.addSprite(this.missingImage);
|
||||
skipFirst = false;
|
||||
bar = ProgressManager.push("Texture creation", 2);
|
||||
|
||||
bar.step("Stitching");
|
||||
stitcher.doStitch();
|
||||
|
||||
Log.info("Created: {}x{} {}-atlas", stitcher.getCurrentWidth(), stitcher.getCurrentHeight(), this.basePath);
|
||||
bar.step("Allocating GL texture");
|
||||
TextureUtil.allocateTextureImpl(this.getGlTextureId(), 0, stitcher.getCurrentWidth(), stitcher.getCurrentHeight());
|
||||
Map<String, TextureAtlasSprite> map = Maps.<String, TextureAtlasSprite>newHashMap(this.mapRegisteredSprites);
|
||||
|
||||
ProgressManager.pop(bar);
|
||||
bar = ProgressManager.push("Texture mipmap and upload", stitcher.getStichSlots().size());
|
||||
|
||||
for (TextureAtlasSprite textureatlassprite1 : stitcher.getStichSlots()) {
|
||||
bar.step(textureatlassprite1.getIconName());
|
||||
if (textureatlassprite1 == this.missingImage || this.generateMipmaps(resourceManager, textureatlassprite1)) {
|
||||
String s = textureatlassprite1.getIconName();
|
||||
map.remove(s);
|
||||
this.mapUploadedSprites.put(s, textureatlassprite1);
|
||||
|
||||
try {
|
||||
TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false);
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Texture being stitched together");
|
||||
crashreportcategory.addCrashSection("Atlas path", this.basePath);
|
||||
crashreportcategory.addCrashSection("Sprite", textureatlassprite1);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
|
||||
if (textureatlassprite1.hasAnimationMetadata()) {
|
||||
this.listAnimatedSprites.add(textureatlassprite1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TextureAtlasSprite textureatlassprite2 : map.values()) {
|
||||
textureatlassprite2.copyFrom(this.missingImage);
|
||||
}
|
||||
|
||||
ProgressManager.pop(bar);
|
||||
}
|
||||
|
||||
private boolean generateMipmaps(IResourceManager resourceManager, final TextureAtlasSprite texture) {
|
||||
ResourceLocation resourcelocation = this.getResourceLocation(texture);
|
||||
IResource iresource = null;
|
||||
label9:
|
||||
{
|
||||
boolean flag;
|
||||
if (texture.hasCustomLoader(resourceManager, resourcelocation)) break label9;
|
||||
try {
|
||||
iresource = resourceManager.getResource(resourcelocation);
|
||||
texture.loadSpriteFrames(iresource, 1);
|
||||
break label9;
|
||||
} catch (RuntimeException runtimeexception) {
|
||||
Log.error("Unable to parse metadata from {}", resourcelocation, runtimeexception);
|
||||
flag = false;
|
||||
} catch (IOException ioexception) {
|
||||
Log.error("Using missing texture, unable to load {}", resourcelocation, ioexception);
|
||||
flag = false;
|
||||
return flag;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(iresource);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
try {
|
||||
texture.generateMipmaps(0);
|
||||
return true;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Applying mipmap");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Sprite being mipmapped");
|
||||
crashreportcategory.setDetail("Sprite name", new ICrashReportDetail<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return texture.getIconName();
|
||||
}
|
||||
});
|
||||
crashreportcategory.setDetail("Sprite size", new ICrashReportDetail<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return texture.getIconWidth() + " x " + texture.getIconHeight();
|
||||
}
|
||||
});
|
||||
crashreportcategory.setDetail("Sprite frames", new ICrashReportDetail<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return texture.getFrameCount() + " frames";
|
||||
}
|
||||
});
|
||||
crashreportcategory.addCrashSection("Mipmap levels", 0);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceLocation getResourceLocation(TextureAtlasSprite p_184396_1_) {
|
||||
ResourceLocation resourcelocation = new ResourceLocation(p_184396_1_.getIconName());
|
||||
return new ResourceLocation(resourcelocation.getResourceDomain(), String.format("%s/%s%s", this.basePath, resourcelocation.getResourcePath(), ".png"));
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
|
||||
//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
@@ -336,8 +337,14 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && inventory != null){
|
||||
SidedInvWrapper sidedInvWrapper = new SidedInvWrapper(inventory, facing);
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(sidedInvWrapper);
|
||||
if(facing != null){
|
||||
SidedInvWrapper sidedInvWrapper = new SidedInvWrapper(inventory, facing);
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(sidedInvWrapper);
|
||||
}else{
|
||||
InvWrapper invWrapper = new InvWrapper(inventory);
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(invWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@@ -13,15 +13,18 @@ package forestry.core.tiles;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockFlowerPot;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
@@ -48,12 +51,26 @@ public abstract class TileUtil {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tile of the specified class, returns null if it is the wrong type or does not exist.
|
||||
* Avoids creating new tile entities when using a ChunkCache (off the main thread).
|
||||
* see {@link BlockFlowerPot#getActualState(IBlockState, IBlockAccess, BlockPos)}
|
||||
*/
|
||||
@Nullable
|
||||
public static <T extends TileEntity> T getTile(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull Class<T> tileClass) {
|
||||
if(pos == null){
|
||||
return null;
|
||||
}
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
|
||||
TileEntity tileEntity;
|
||||
|
||||
if (world instanceof ChunkCache) {
|
||||
ChunkCache chunkCache = (ChunkCache) world;
|
||||
tileEntity = chunkCache.getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK);
|
||||
} else {
|
||||
tileEntity = world.getTileEntity(pos);
|
||||
}
|
||||
|
||||
if (tileClass.isInstance(tileEntity)) {
|
||||
return tileClass.cast(tileEntity);
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,7 @@ import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -62,7 +63,7 @@ public class CamouflageUtil {
|
||||
if(pos == null || world == null){
|
||||
return null;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = TileUtil.getTile(world, pos, TileEntity.class);
|
||||
if(tile instanceof ICamouflagedTile){
|
||||
ICamouflagedTile block = (ICamouflagedTile) tile;
|
||||
String type = block.getCamouflageType();
|
||||
@@ -86,7 +87,7 @@ public class CamouflageUtil {
|
||||
if(pos == null || world == null){
|
||||
return null;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = TileUtil.getTile(world, pos, TileEntity.class);
|
||||
if(tile instanceof ICamouflagedTile){
|
||||
ICamouflagedTile block = (ICamouflagedTile) tile;
|
||||
String type = block.getCamouflageType();
|
||||
|
||||
@@ -227,7 +227,7 @@ public class ClimateUtil implements IClimateHelper {
|
||||
}
|
||||
|
||||
public static void readPositionData(IClimatePosition position, DataInputStreamForestry data) throws IOException {
|
||||
position.setHumidity(data.readFloat());
|
||||
position.setTemperature(data.readFloat());
|
||||
position.setHumidity(data.readFloat());
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ package forestry.core.utils;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -37,7 +38,7 @@ public abstract class EntityUtil {
|
||||
living.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0f), 0.0f);
|
||||
living.rotationYawHead = living.rotationYaw;
|
||||
living.renderYawOffset = living.rotationYaw;
|
||||
living.onInitialSpawn(null, null);
|
||||
living.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(x, y, z)), null);
|
||||
world.spawnEntityInWorld(living);
|
||||
living.playLivingSound();
|
||||
return living;
|
||||
|
||||
@@ -29,10 +29,10 @@ import forestry.api.genetics.ILeafTranslator;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.api.genetics.ISaplingTranslator;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.ISpeciesRootPollinatable;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.api.lepidopterology.IButterflyNursery;
|
||||
import forestry.arboriculture.genetics.pollination.CheckPollinatableTree;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.genetics.ItemGE;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -90,9 +90,12 @@ public class GeneticsUtil {
|
||||
return (IPollinatable) tile;
|
||||
}
|
||||
|
||||
ITree pollen = getPollen(world, pos);
|
||||
IIndividual pollen = getPollen(world, pos);
|
||||
if (pollen != null) {
|
||||
return new CheckPollinatableTree(pollen);
|
||||
ISpeciesRoot root = pollen.getGenome().getSpeciesRoot();
|
||||
if(root instanceof ISpeciesRootPollinatable){
|
||||
return ((ISpeciesRootPollinatable)root).createPollinatable(pollen);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -108,11 +111,11 @@ public class GeneticsUtil {
|
||||
return (IPollinatable) tile;
|
||||
}
|
||||
|
||||
if (Config.pollinateVanillaTrees) {
|
||||
ITree pollen = getPollen(world, pos);
|
||||
if (pollen != null) {
|
||||
pollen.setLeaves(world, owner, pos);
|
||||
return (IPollinatable) world.getTileEntity(pos);
|
||||
final IIndividual pollen = getPollen(world, pos);
|
||||
if(pollen != null){
|
||||
ISpeciesRoot root = pollen.getGenome().getSpeciesRoot();
|
||||
if(root instanceof ISpeciesRootPollinatable){
|
||||
return ((ISpeciesRootPollinatable) root).tryConvertToPollinatable(owner, world, pos, pollen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +126,7 @@ public class GeneticsUtil {
|
||||
* Gets pollen from a location. Does not affect the pollen source.
|
||||
*/
|
||||
@Nullable
|
||||
public static ITree getPollen(World world, final BlockPos pos) {
|
||||
public static IIndividual getPollen(World world, final BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof ICheckPollinatable) {
|
||||
|
||||
Loaded 100 of 196 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user