mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c1b7927d6 | ||
|
|
bf3ac85d88 | ||
|
|
d09b663ba6 | ||
|
|
3beacb998d | ||
|
|
52e7f95534 | ||
|
|
cc4cc558b8 | ||
|
|
956aaca10c | ||
|
|
23f7c9c7d9 | ||
|
|
3684792a39 | ||
|
|
0e81f373f0 | ||
|
|
59d1d3456b | ||
|
|
15fe11094b | ||
|
|
790e9b9fba | ||
|
|
c7ef2ef807 | ||
|
|
11fa7bbf75 | ||
|
|
4c2cbd77c1 |
No files matched your search
+1
-1
Submodule api/forestry updated: d0444f3ca9...1c9fb5e23f.
@@ -2,4 +2,4 @@ mcversion=1.7.10
|
||||
forgeversion=10.13.3.1370-1.7.10
|
||||
version_major=4
|
||||
version_minor=0
|
||||
version_patch=7
|
||||
version_patch=11
|
||||
+1
-1
Submodule lang updated: fc688b7589...2843053395.
@@ -46,14 +46,18 @@ import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerAcceptableRule;
|
||||
import forestry.api.genetics.IFlowerGrowthHelper;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
public final class FlowerRegistry implements IFlowerRegistry {
|
||||
public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelper {
|
||||
|
||||
private final Set<String> defaultFlowerTypes = ImmutableSet.of(
|
||||
FlowerManager.FlowerTypeVanilla,
|
||||
@@ -67,13 +71,15 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
FlowerManager.FlowerTypeGourd
|
||||
);
|
||||
|
||||
private final HashMultimap<String, IFlowerAcceptableRule> registeredRules; // custom check
|
||||
private final HashMultimap<String, Block> registeredBlocks; // quick first check
|
||||
private final HashMultimap<String, IFlower> registeredFlowers; // full check
|
||||
private final HashMultimap<String, Flower> registeredFlowers; // full check
|
||||
|
||||
private final ArrayListMultimap<String, IFlowerGrowthRule> growthRules;
|
||||
private final Map<String, TreeMap<Double, IFlower>> chances;
|
||||
private final Map<String, TreeMap<Double, Flower>> chances;
|
||||
|
||||
public FlowerRegistry() {
|
||||
this.registeredRules = HashMultimap.create();
|
||||
this.registeredBlocks = HashMultimap.create();
|
||||
this.registeredFlowers = HashMultimap.create();
|
||||
this.growthRules = ArrayListMultimap.create();
|
||||
@@ -92,6 +98,17 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
registerFlower(block, meta, 0.0, flowerTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAcceptableFlowerRule(IFlowerAcceptableRule acceptableFlower, String... flowerTypes) {
|
||||
for (String flowerType : flowerTypes) {
|
||||
if (defaultFlowerTypes.contains(flowerType)) {
|
||||
Log.severe("IFlowerAcceptableRules are too slow to be applied to Forestry's built-in flower type: " + flowerType + ".");
|
||||
} else {
|
||||
registeredRules.put(flowerType, acceptableFlower);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlantableFlower(Block block, int meta, double weight, String... flowerTypes) {
|
||||
registerFlower(block, meta, weight, flowerTypes);
|
||||
@@ -115,7 +132,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
throw new NullPointerException("Tried to register flower with null type. " + block);
|
||||
}
|
||||
|
||||
Set<IFlower> flowers = this.registeredFlowers.get(flowerType);
|
||||
Set<Flower> flowers = this.registeredFlowers.get(flowerType);
|
||||
flowers.add(newFlower);
|
||||
|
||||
Set<Block> blocks = this.registeredBlocks.get(flowerType);
|
||||
@@ -139,8 +156,9 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<IFlowerAcceptableRule> acceptableRules = this.registeredRules.get(flowerType);
|
||||
Set<Block> acceptedBlocks = this.registeredBlocks.get(flowerType);
|
||||
Set<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
|
||||
Set<Flower> acceptedFlowers = this.registeredFlowers.get(flowerType);
|
||||
World world = beeHousing.getWorld();
|
||||
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
|
||||
@@ -153,6 +171,12 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
|
||||
Vect posBlock = Vect.add(housingPos, posCurrent);
|
||||
|
||||
for (IFlowerAcceptableRule acceptableRule : acceptableRules) {
|
||||
if (acceptableRule.isAcceptableFlower(flowerType, world, posBlock.x, posBlock.y, posBlock.z)) {
|
||||
return new ChunkCoordinates(posBlock.x, posBlock.y, posBlock.z);
|
||||
}
|
||||
}
|
||||
|
||||
if (isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, posBlock.x, posBlock.y, posBlock.z)) {
|
||||
return new ChunkCoordinates(posBlock.x, posBlock.y, posBlock.z);
|
||||
}
|
||||
@@ -167,13 +191,20 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<IFlowerAcceptableRule> acceptedCustom = this.registeredRules.get(flowerType);
|
||||
for (IFlowerAcceptableRule acceptableFlower : acceptedCustom) {
|
||||
if (acceptableFlower.isAcceptableFlower(flowerType, world, x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Set<Block> acceptedBlocks = this.registeredBlocks.get(flowerType);
|
||||
Set<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
|
||||
Set<Flower> acceptedFlowers = this.registeredFlowers.get(flowerType);
|
||||
|
||||
return isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, x, y, z);
|
||||
}
|
||||
|
||||
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<IFlower> acceptedFlowers, World world, int x, int y, int z) {
|
||||
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers, World world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
final int meta;
|
||||
@@ -221,7 +252,15 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
}
|
||||
|
||||
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
|
||||
if (rule.growFlower(this, flowerType, world, individual, x, y, z)) {
|
||||
boolean success;
|
||||
try {
|
||||
success = rule.growFlower(this, flowerType, world, x, y, z);
|
||||
} catch (Throwable ignored) {
|
||||
// legacy method
|
||||
success = rule.growFlower(this, flowerType, world, individual, x, y, z);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -231,7 +270,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
|
||||
@Override
|
||||
public Set<IFlower> getAcceptableFlowers(String flowerType) {
|
||||
return this.registeredFlowers.get(flowerType);
|
||||
return ImmutableSet.<IFlower>copyOf(this.registeredFlowers.get(flowerType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,7 +286,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
|
||||
@Override
|
||||
public IFlower getRandomPlantableFlower(String flowerType, Random rand) {
|
||||
TreeMap<Double, IFlower> chancesMap = getChancesMap(flowerType);
|
||||
TreeMap<Double, Flower> chancesMap = getChancesMap(flowerType);
|
||||
double maxKey = chancesMap.lastKey() + 1.0;
|
||||
return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey));
|
||||
}
|
||||
@@ -257,11 +296,11 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
return new ArrayList<>(Sets.union(defaultFlowerTypes, registeredFlowers.keySet()));
|
||||
}
|
||||
|
||||
private TreeMap<Double, IFlower> getChancesMap(String flowerType) {
|
||||
private TreeMap<Double, Flower> getChancesMap(String flowerType) {
|
||||
if (!this.chances.containsKey(flowerType)) {
|
||||
TreeMap<Double, IFlower> flowerChances = new TreeMap<>();
|
||||
TreeMap<Double, Flower> flowerChances = new TreeMap<>();
|
||||
double count = 0.0;
|
||||
for (IFlower flower : this.registeredFlowers.get(flowerType)) {
|
||||
for (Flower flower : this.registeredFlowers.get(flowerType)) {
|
||||
if (flower.isPlantable()) {
|
||||
flowerChances.put(count, flower);
|
||||
count += flower.getWeight();
|
||||
@@ -273,13 +312,19 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
}
|
||||
|
||||
private void registerVanillaGrowthRules() {
|
||||
registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new VanillaFlowerPotGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
|
||||
registerGrowthRule(new GrowthRuleDirtGrass(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new GrowthRuleSnow(), FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new GrowthRuleFlowerPot(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
|
||||
FlowerManager.FlowerTypeJungle);
|
||||
registerGrowthRule(new VanillaMyceliumGrowthRule(), FlowerManager.FlowerTypeMushrooms);
|
||||
registerGrowthRule(new VanillaDefaultGrowthRule(), FlowerManager.FlowerTypeEnd);
|
||||
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
|
||||
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.wheat), FlowerManager.FlowerTypeWheat);
|
||||
registerGrowthRule(new GrowthRuleMycelium(), FlowerManager.FlowerTypeMushrooms);
|
||||
registerGrowthRule(new GrowthRuleNone(), FlowerManager.FlowerTypeEnd);
|
||||
registerGrowthRule(new GrowthRuleFertilize(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
|
||||
registerGrowthRule(new GrowthRuleFertilize(Blocks.wheat), FlowerManager.FlowerTypeWheat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantRandomFlower(String flowerType, World world, int x, int y, int z) {
|
||||
IFlower flower = getRandomPlantableFlower(flowerType, world.rand);
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -15,12 +15,13 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthHelper;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
|
||||
public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
@@ -37,4 +38,18 @@ public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return helper.plantRandomFlower(flowerType, world, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
+12
-2
@@ -16,20 +16,30 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlowerGrowthHelper;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule {
|
||||
public class GrowthRuleFertilize implements IFlowerGrowthRule {
|
||||
|
||||
private final List<Block> allowedItems;
|
||||
|
||||
public VanillaFertilizeGrowthRule(Block... allowedItems) {
|
||||
public GrowthRuleFertilize(Block... allowedItems) {
|
||||
this.allowedItems = Arrays.asList(allowedItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
return growFlower(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
return growFlower(world, x, y, z);
|
||||
}
|
||||
|
||||
private boolean growFlower(World world, int x, int y, int z) {
|
||||
Block ground = world.getBlock(x, y, z);
|
||||
int groundMeta;
|
||||
for (Block b : this.allowedItems) {
|
||||
+10
-1
@@ -17,15 +17,24 @@ import net.minecraft.tileentity.TileEntityFlowerPot;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlowerGrowthHelper;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
|
||||
public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
return growFlower(flowerType, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
return growFlower(flowerType, world, x, y, z);
|
||||
}
|
||||
|
||||
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileEntityFlowerPot)) {
|
||||
return false;
|
||||
+16
-1
@@ -15,12 +15,13 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthHelper;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
|
||||
public class GrowthRuleMycelium implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
@@ -37,4 +38,18 @@ public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.mycelium) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return helper.plantRandomFlower(flowerType, world, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
+7
-1
@@ -12,15 +12,21 @@ package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlowerGrowthHelper;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaDefaultGrowthRule implements IFlowerGrowthRule {
|
||||
public class GrowthRuleNone implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+16
-1
@@ -15,12 +15,13 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthHelper;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
|
||||
public class GrowthRuleSnow implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
@@ -37,4 +38,18 @@ public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
if (world.getBlock(x, y, z) != Blocks.snow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return helper.plantRandomFlower(flowerType, world, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
@@ -741,7 +742,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect posBlock = Vect.add(housingPos, randomPos, offset);
|
||||
|
||||
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) {
|
||||
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock.x, posBlock.y, posBlock.z)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -41,10 +42,12 @@ import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.render.IconProviderWood;
|
||||
import forestry.arboriculture.tiles.TileWood;
|
||||
import forestry.core.render.ParticleHelper;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntityProvider {
|
||||
|
||||
private final ParticleHelper.Callback particleCallback;
|
||||
private final boolean fireproof;
|
||||
|
||||
public BlockArbFence(boolean fireproof) {
|
||||
@@ -57,6 +60,8 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
|
||||
setHarvestLevel("axe", 0);
|
||||
setStepSound(soundTypeWood);
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
|
||||
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@@ -174,4 +179,17 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
|
||||
public boolean isFireproof() {
|
||||
return fireproof;
|
||||
}
|
||||
|
||||
/* Particles */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -37,9 +38,11 @@ import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.render.IconProviderWood;
|
||||
import forestry.arboriculture.tiles.TileWood;
|
||||
import forestry.core.render.ParticleHelper;
|
||||
|
||||
public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEntityProvider {
|
||||
|
||||
private final ParticleHelper.Callback particleCallback;
|
||||
private final boolean fireproof;
|
||||
|
||||
public BlockArbStairs(Block par2Block, boolean fireproof) {
|
||||
@@ -51,6 +54,8 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("axe", 0);
|
||||
|
||||
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@@ -126,4 +131,17 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileWood();
|
||||
}
|
||||
|
||||
/* Particles */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -41,9 +42,11 @@ import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.render.IconProviderWood;
|
||||
import forestry.arboriculture.tiles.TileWood;
|
||||
import forestry.core.render.ParticleHelper;
|
||||
|
||||
public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped, ITileEntityProvider {
|
||||
|
||||
private final ParticleHelper.Callback particleCallback;
|
||||
private final boolean fireproof;
|
||||
|
||||
public BlockSlab(boolean fireproof) {
|
||||
@@ -57,6 +60,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
setResistance(5.0F);
|
||||
setStepSound(soundTypeWood);
|
||||
setHarvestLevel("axe", 0);
|
||||
|
||||
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,4 +188,17 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
public Item getItem(World world, int x, int y, int z) {
|
||||
return Item.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
/* Particles */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -35,10 +36,12 @@ import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.render.IconProviderWood;
|
||||
import forestry.arboriculture.tiles.TileWood;
|
||||
import forestry.core.render.ParticleHelper;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
|
||||
public abstract class BlockWood extends Block implements ITileEntityProvider, IWoodTyped {
|
||||
|
||||
private final ParticleHelper.Callback particleCallback;
|
||||
private final String blockKind;
|
||||
private final boolean fireproof;
|
||||
|
||||
@@ -49,6 +52,8 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
|
||||
|
||||
setStepSound(soundTypeWood);
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
|
||||
particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,4 +143,16 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract IIcon getIcon(IBlockAccess world, int x, int y, int z, int side);
|
||||
|
||||
/* Particles */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,12 @@ import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
import forestry.core.genetics.Individual;
|
||||
import forestry.core.genetics.alleles.Allele;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class Tree extends Individual implements ITree, IPlantable {
|
||||
@@ -222,6 +224,10 @@ public class Tree extends Individual implements ITree, IPlantable {
|
||||
@Override
|
||||
public void setLeaves(World world, GameProfile owner, int x, int y, int z) {
|
||||
genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, false);
|
||||
TileLeaves leaves = TileUtil.getTile(world, x, y, z, TileLeaves.class);
|
||||
if (leaves != null) {
|
||||
leaves.setTree(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,35 +49,20 @@ public class ParticleHelper {
|
||||
|
||||
if (sideHit == 0) {
|
||||
py = (double) y + block.getBlockBoundsMinY() - (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 1) {
|
||||
} else if (sideHit == 1) {
|
||||
py = (double) y + block.getBlockBoundsMaxY() + (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 2) {
|
||||
} else if (sideHit == 2) {
|
||||
pz = (double) z + block.getBlockBoundsMinZ() - (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 3) {
|
||||
} else if (sideHit == 3) {
|
||||
pz = (double) z + block.getBlockBoundsMaxZ() + (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 4) {
|
||||
} else if (sideHit == 4) {
|
||||
px = (double) x + block.getBlockBoundsMinX() - (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 5) {
|
||||
} else if (sideHit == 5) {
|
||||
px = (double) x + block.getBlockBoundsMaxX() + (double) b;
|
||||
}
|
||||
|
||||
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, meta);
|
||||
fx.setParticleIcon(block.getIcon(world, x, y, z, 0));
|
||||
|
||||
if (callback != null) {
|
||||
callback.addHitEffects(fx, world, x, y, z, meta);
|
||||
}
|
||||
|
||||
callback.addHitEffects(fx, world, x, y, z, meta, sideHit);
|
||||
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
||||
|
||||
return true;
|
||||
@@ -90,7 +75,6 @@ public class ParticleHelper {
|
||||
* the location is this block.
|
||||
*
|
||||
* @param world The current world
|
||||
* @param block
|
||||
* @param x X position to spawn the particle
|
||||
* @param y Y position to spawn the particle
|
||||
* @param z Z position to spawn the particle
|
||||
@@ -115,12 +99,7 @@ public class ParticleHelper {
|
||||
int random = rand.nextInt(6);
|
||||
|
||||
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, block, random, meta);
|
||||
fx.setParticleIcon(block.getIcon(world, x, y, z, 0));
|
||||
|
||||
if (callback != null) {
|
||||
callback.addDestroyEffects(fx, world, x, y, z, meta);
|
||||
}
|
||||
|
||||
callback.addDestroyEffects(fx, world, x, y, z, meta);
|
||||
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -132,9 +111,35 @@ public class ParticleHelper {
|
||||
public interface Callback {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta);
|
||||
void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta, int side);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta);
|
||||
}
|
||||
|
||||
public static class DefaultCallback implements ParticleHelper.Callback {
|
||||
|
||||
private final Block block;
|
||||
|
||||
public DefaultCallback(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta, int side) {
|
||||
setTexture(fx, world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) {
|
||||
setTexture(fx, world, x, y, z, 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void setTexture(EntityDiggingFX fx, World world, int x, int y, int z, int side) {
|
||||
fx.setParticleIcon(block.getIcon(world, x, y, z, side));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,11 +104,7 @@ public abstract class SlotUtil {
|
||||
return shiftToHotbar(inventorySlots, stackInSlot);
|
||||
}
|
||||
} else {
|
||||
boolean shifted = shiftToHotbar(inventorySlots, stackInSlot);
|
||||
if (!shifted) {
|
||||
shifted = shiftToPlayerInventoryNoHotbar(inventorySlots, stackInSlot);
|
||||
}
|
||||
return shifted;
|
||||
return shiftToPlayerInventory(inventorySlots, stackInSlot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,38 +154,31 @@ public abstract class SlotUtil {
|
||||
}
|
||||
|
||||
private static boolean shiftItemStackToRange(List inventorySlots, ItemStack stackToShift, int start, int count) {
|
||||
boolean changed = false;
|
||||
if (stackToShift.isStackable()) {
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot != null && ItemStackUtil.isIdenticalItem(stackInSlot, stackToShift)) {
|
||||
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
if (resultingStackSize <= max) {
|
||||
stackToShift.stackSize = 0;
|
||||
stackInSlot.stackSize = resultingStackSize;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
} else if (stackInSlot.stackSize < max) {
|
||||
stackToShift.stackSize -= max - stackInSlot.stackSize;
|
||||
stackInSlot.stackSize = max;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean changed = shiftItemStackToRangeMerge(inventorySlots, stackToShift, start, count);
|
||||
changed |= shiftItemStackToRangeOpenSlots(inventorySlots, stackToShift, start, count);
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static boolean shiftItemStackToRangeMerge(List inventorySlots, ItemStack stackToShift, int start, int count) {
|
||||
if (stackToShift == null || !stackToShift.isStackable() || stackToShift.stackSize <= 0) {
|
||||
return false;
|
||||
}
|
||||
if (stackToShift.stackSize > 0) {
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot == null) {
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
stackInSlot = stackToShift.copy();
|
||||
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
|
||||
stackToShift.stackSize -= stackInSlot.stackSize;
|
||||
slot.putStack(stackInSlot);
|
||||
|
||||
boolean changed = false;
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot != null && ItemStackUtil.isIdenticalItem(stackInSlot, stackToShift)) {
|
||||
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
if (resultingStackSize <= max) {
|
||||
stackToShift.stackSize = 0;
|
||||
stackInSlot.stackSize = resultingStackSize;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
} else if (stackInSlot.stackSize < max) {
|
||||
stackToShift.stackSize -= max - stackInSlot.stackSize;
|
||||
stackInSlot.stackSize = max;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
@@ -198,6 +187,28 @@ public abstract class SlotUtil {
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static boolean shiftItemStackToRangeOpenSlots(List inventorySlots, ItemStack stackToShift, int start, int count) {
|
||||
if (stackToShift == null || stackToShift.stackSize <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot == null) {
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
stackInSlot = stackToShift.copy();
|
||||
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
|
||||
stackToShift.stackSize -= stackInSlot.stackSize;
|
||||
slot.putStack(stackInSlot);
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static final int playerInventorySize = 9 * 4;
|
||||
private static final int playerHotbarSize = 9;
|
||||
|
||||
@@ -209,6 +220,19 @@ public abstract class SlotUtil {
|
||||
return SlotUtil.isSlotInRange(slotIndex, playerInventorySize - playerHotbarSize, playerInventorySize);
|
||||
}
|
||||
|
||||
private static boolean shiftToPlayerInventory(List inventorySlots, ItemStack stackInSlot) {
|
||||
int playerHotbarStart = playerInventorySize - playerHotbarSize;
|
||||
|
||||
// try to merge with existing stacks, hotbar first
|
||||
boolean shifted = shiftItemStackToRangeMerge(inventorySlots, stackInSlot, playerHotbarStart, playerHotbarSize);
|
||||
shifted |= shiftItemStackToRangeMerge(inventorySlots, stackInSlot, 0, playerHotbarStart);
|
||||
|
||||
// shift to open slots, hotbar first
|
||||
shifted |= shiftItemStackToRangeOpenSlots(inventorySlots, stackInSlot, playerHotbarStart, playerHotbarSize);
|
||||
shifted |= shiftItemStackToRangeOpenSlots(inventorySlots, stackInSlot, 0, playerHotbarStart);
|
||||
return shifted;
|
||||
}
|
||||
|
||||
private static boolean shiftToPlayerInventoryNoHotbar(List inventorySlots, ItemStack stackInSlot) {
|
||||
int playerHotbarStart = playerInventorySize - playerHotbarSize;
|
||||
return shiftItemStackToRange(inventorySlots, stackInSlot, 0, playerHotbarStart);
|
||||
|
||||
@@ -114,6 +114,11 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
|
||||
@Override
|
||||
public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output, FluidStack liquid) {
|
||||
// assume that fermenter recipes want to use Forestry's honey and not the legacy "fluid.honey"
|
||||
if (Fluids.LEGACY_HONEY.is(liquid)) {
|
||||
liquid = Fluids.HONEY.getFluid(liquid.amount);
|
||||
}
|
||||
|
||||
recipes.add(new Recipe(resource, fermentationValue, modifier, output, liquid));
|
||||
if (liquid != null) {
|
||||
recipeFluidInputs.add(liquid.getFluid());
|
||||
|
||||
@@ -404,19 +404,14 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
containerRecipes.put(emptyContainer, new SqueezerContainerRecipe(emptyContainer, timePerItem, remnants, chance));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ISqueezerContainerRecipe findMatchingContainerRecipe(ItemStack filledContainer) {
|
||||
ItemStack emptyContainer = FluidHelper.getEmptyContainer(filledContainer);
|
||||
if (emptyContainer == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ISqueezerContainerRecipe containerRecipe = containerRecipes.get(emptyContainer);
|
||||
if (containerRecipe != null) {
|
||||
return containerRecipe;
|
||||
}
|
||||
|
||||
// default recipe for unregistered fluid items, has no remnants
|
||||
return new SqueezerContainerRecipe(emptyContainer, 10, null, 0);
|
||||
return containerRecipes.get(emptyContainer);
|
||||
}
|
||||
|
||||
public static ISqueezerRecipe findMatchingRecipe(ItemStack[] items) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import forestry.core.network.GuiId;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import forestry.factory.recipes.RecipeMemory;
|
||||
|
||||
@@ -194,11 +195,20 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!itemStack.getItem().hasContainerItem(itemStack)) {
|
||||
continue;
|
||||
ItemStack container = null;
|
||||
|
||||
if (itemStack.getItem().hasContainerItem(itemStack)) {
|
||||
container = itemStack.getItem().getContainerItem(itemStack);
|
||||
} else if (itemStack.stackSize > 1) {
|
||||
// TerraFirmaCraft's crafting event handler does some tricky stuff with its tools.
|
||||
// It sets the tool's stack size to 2 instead of using a container.
|
||||
container = ItemStackUtil.createSplitStack(itemStack, itemStack.stackSize - 1);
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
|
||||
ItemStack container = itemStack.getItem().getContainerItem(itemStack);
|
||||
if (container == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (container != null && container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityDiggingFX;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -47,12 +46,12 @@ import forestry.plugins.PluginFarming;
|
||||
|
||||
public class BlockFarm extends BlockStructure {
|
||||
|
||||
private static BlockFarm instance;
|
||||
private final ParticleHelper.Callback particleCallback;
|
||||
|
||||
public BlockFarm() {
|
||||
super(Material.rock);
|
||||
setHardness(1.0f);
|
||||
instance = this;
|
||||
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,40 +161,6 @@ public class BlockFarm extends BlockStructure {
|
||||
EnumFarmBlockTexture.registerIcons(register);
|
||||
}
|
||||
|
||||
private static class ParticleCallback implements ParticleHelper.Callback {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) {
|
||||
setTexture(fx, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) {
|
||||
setTexture(fx, world, x, y, z);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static void setTexture(EntityDiggingFX fx, World world, int x, int y, int z) {
|
||||
fx.setParticleIcon(instance.getIcon(world, x, y, z, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private static final ParticleHelper.Callback callback = new ParticleCallback();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addHitEffects(worldObj, instance, target, effectRenderer, callback);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addDestroyEffects(worldObj, instance, x, y, z, meta, effectRenderer, callback);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
@@ -237,11 +202,6 @@ public class BlockFarm extends BlockStructure {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return world.getBlockMetadata(x, y, z) == 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
@@ -260,4 +220,22 @@ public class BlockFarm extends BlockStructure {
|
||||
return block.getIcon(side, base.getItemDamage());
|
||||
}
|
||||
|
||||
/* Particles */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return world.getBlockMetadata(x, y, z) == 5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.food.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -71,7 +72,7 @@ public class ItemBeverage extends ItemForestryFood {
|
||||
}
|
||||
|
||||
public static List<IBeverageEffect> loadEffects(ItemStack stack) {
|
||||
List<IBeverageEffect> effectsList = Collections.emptyList();
|
||||
List<IBeverageEffect> effectsList = new ArrayList<>();
|
||||
|
||||
NBTTagCompound nbttagcompound = stack.getTagCompound();
|
||||
if (nbttagcompound == null) {
|
||||
|
||||
@@ -109,8 +109,8 @@ public class PluginHarvestCraft extends ForestryPlugin {
|
||||
|
||||
ImmutableList<String> spices = ImmutableList.of(
|
||||
"ginger",
|
||||
"spiceleaf",
|
||||
"mustardseed"
|
||||
"spiceleaf"
|
||||
//"mustardseed" Mustard is inconsistent and annoying.
|
||||
);
|
||||
|
||||
ImmutableList<String> vegetables = ImmutableList.of(
|
||||
@@ -301,6 +301,19 @@ public class PluginHarvestCraft extends ForestryPlugin {
|
||||
}
|
||||
plants.add(cropName);
|
||||
}
|
||||
ItemStack mustardCropSeed = GameRegistry.findItemStack(HC,"mustard" + "seedItem",1);
|
||||
Block mustardCropBlock = GameRegistry.findBlock(HC,"pam"+"mustardseeds" + "Crop");
|
||||
ItemStack mustardFruit = GameRegistry.findItemStack(HC,"mustard" + "seedsItem",1);
|
||||
if (mustardCropSeed != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{mustardCropSeed}, Fluids.SEEDOIL.getFluid(seedamount));
|
||||
}
|
||||
if (mustardCropSeed != null && mustardCropBlock != null) {
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(mustardCropSeed, mustardCropBlock, 7));
|
||||
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(mustardCropBlock, 7));
|
||||
}
|
||||
if (mustardFruit != null) {
|
||||
RecipeUtil.addFermenterRecipes(mustardFruit, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
}
|
||||
|
||||
for (String plantName : plants.build()) {
|
||||
ItemStack plant = GameRegistry.findItemStack(HC, plantName + "Item", 1);
|
||||
|
||||
@@ -140,8 +140,10 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
||||
|
||||
ImmutableList<String> betaSeeds = ImmutableList.of(
|
||||
"Air",
|
||||
"Airshard",
|
||||
"Aluminium",
|
||||
"Alumite",
|
||||
"Amber",
|
||||
"Ardite",
|
||||
"Blaze",
|
||||
"Blizz",
|
||||
@@ -150,18 +152,25 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
||||
"Chicken",
|
||||
"Coal",
|
||||
"Cobalt",
|
||||
"ConductiveIron",
|
||||
"Copper",
|
||||
"Cow",
|
||||
"Creeper",
|
||||
"DarkSteel",
|
||||
"Diamond",
|
||||
"Draconium",
|
||||
"Dye",
|
||||
"Earth",
|
||||
"Earthshard",
|
||||
"ElectricalSteel",
|
||||
"Electrum",
|
||||
"Emerald",
|
||||
"Enderium",
|
||||
"Enderman",
|
||||
"EnergeticAlloy",
|
||||
"Experience",
|
||||
"Fire",
|
||||
"Fireshard",
|
||||
"Fluix",
|
||||
"Ghast",
|
||||
"Glowstone",
|
||||
@@ -178,11 +187,15 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
||||
"Nether",
|
||||
"Nickel",
|
||||
"Obsidian",
|
||||
"Ordershard",
|
||||
"Osmium",
|
||||
"Peridot",
|
||||
"Pig",
|
||||
"Platinum",
|
||||
"PulsatingIron",
|
||||
"Quartz",
|
||||
"Quicksilver",
|
||||
"RedstoneAlloy",
|
||||
"Redstone",
|
||||
"Rubber",
|
||||
"Ruby",
|
||||
@@ -193,12 +206,16 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
||||
"Silver",
|
||||
"Skeleton",
|
||||
"Slime",
|
||||
"Soularium",
|
||||
"Spider",
|
||||
"Steel",
|
||||
"Sulfur",
|
||||
"Terrasteel",
|
||||
"Thaumium",
|
||||
"Tin",
|
||||
"VibrantAlloy",
|
||||
"Water",
|
||||
"Watershard",
|
||||
"Wither",
|
||||
"Yellorite"
|
||||
);
|
||||
@@ -229,7 +246,8 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
||||
addRecipes("_Seeds", "_Crop", seedName, seedAmount);
|
||||
}
|
||||
for (String seedName : betaSeeds) {
|
||||
addBetaRecipes("Seeds", "Crop", seedName);
|
||||
addBetaRecipes("Seeds", "Crop", seedName, "");
|
||||
addBetaRecipes("Seeds", "Crop", seedName, "magicalcrops_");
|
||||
}
|
||||
|
||||
Item cropProduce = GameRegistry.findItem(MagCrop, MagCrop + "_CropProduce");
|
||||
@@ -252,9 +270,9 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addBetaRecipes(String seedSuffix, String cropSuffix, String name) {
|
||||
ItemStack seed = GameRegistry.findItemStack(MagCrop, MagCrop + "_" + name + seedSuffix, 1);
|
||||
Block crop = GameRegistry.findBlock(MagCrop, MagCrop + "_" + name + cropSuffix);
|
||||
private static void addBetaRecipes(String seedSuffix, String cropSuffix, String name, String middlefix) {
|
||||
ItemStack seed = GameRegistry.findItemStack(MagCrop, middlefix + name + seedSuffix, 1);
|
||||
Block crop = GameRegistry.findBlock(MagCrop, middlefix + name + cropSuffix);
|
||||
if (seed != null && crop != null && Config.isMagicalCropsSupportEnabled()) {
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seed, crop, 7));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user