Compare commits

...
23 Commits
Author SHA1 Message Date
mezz 856322b208 Update Forge to fix the crash with cactus placement and BoP grass 2016-06-03 17:29:54 -07:00
mezz 42425e3500 Fix #1281 Crash when trying to place Forestry tiles above Y=255 2016-06-03 16:35:06 -07:00
mezz cde076e702 Fix #1280 Bees can find flowers at very different Y levels in some cases 2016-06-03 16:30:27 -07:00
mezz b5f60d73e3 Fix #1278 Wild bees don't hurt if you wear any 1 piece of Apiarist gear 2016-06-03 16:19:45 -07:00
mezz f82d123b7f Fix #1273 Villagers unable to open forestry doors 2016-06-03 16:07:34 -07:00
mezz ca17801c86 Speed up the check for if a block position is currently in a greenhouse 2016-06-03 15:54:44 -07:00
mezz 33d1685713 Fix #1275 block placement lag when constructing a massive greenhouse 2016-06-03 15:26:57 -07:00
mezz 69c024811f Do not bake leaves based on position 2016-06-03 14:45:00 -07:00
Nedelosk 4dd95625e1 Fix #1244 Opening Greenhouse GUI causes a drop in fps, from 90fps to 6fps(in my case) 2016-06-03 23:11:52 +02:00
mezz 6adcde4a75 Fix NoClassDefFoundError: TextureAtlasSprite 2016-06-03 07:34:38 -07:00
mezz 2f06c777b2 Fix #1246 Greenhouse control redstone logic is inverted 2016-06-03 06:25:29 -07:00
mezz 32f295b16c Fix #1254 Chest bounding boxes are too large 2016-06-03 06:22:14 -07:00
mezz ef4c65c6e6 Fix some bee particles showing up as very dark 2016-06-03 06:09:56 -07:00
mezz ba313a9dfe Fix desync causing hives to have no active bees 2016-06-03 06:09:07 -07:00
mezz 8f36c2a6fc Route more bees to flowers than to exploring 2016-06-03 06:08:24 -07:00
mezz 149a5b6128 Update Forge 2016-06-03 06:08:04 -07:00
mezz 56b871eca1 Improve bee particle performance: do not render when too far away 2016-06-03 04:30:42 -07:00
mezz c09cdcdb64 Add more varied bee particles 2016-06-03 04:30:12 -07:00
mezz 2f66d0ea82 Fix hives only spawning Forest bees 2016-06-03 04:24:53 -07:00
mezz ac224823be Reduce random bee damage if you haven't hit the hive 2016-06-03 04:24:33 -07:00
mezz 1eca6e41af Improve bee particle performance 2016-06-02 17:16:15 -07:00
mezz 94bd65ee8e Improve greenhouse error messages. 2016-06-02 16:24:00 -07:00
mezz 795b154eb5 Fix #1263 Crash when lighting TNT on top of wood pile block 2016-06-02 13:19:41 -07:00
38 changed files with 638 additions and 190 deletions

No files matched your search

+2 -2
View File
@@ -1,9 +1,9 @@
mcversion=1.9.4
forgeversion=12.17.0.1932-1.9.4
forgeversion=12.17.0.1944
mcp_mappings=snapshot_20160525
jei_version=3.4.0.+
version_major=5
version_minor=0
version_patch=3
version_patch=5
+1 -1
Submodule lang updated: 53d7c93f90...0e7f1e47f1.
+1 -1
View File
@@ -49,7 +49,7 @@ import forestry.plugins.PluginManager;
name = "Forestry",
version = Constants.VERSION,
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
dependencies = "required-after:Forge@[12.17.0.1932,);"
dependencies = "required-after:Forge@[12.17.0.1941,);"
+ "after:Buildcraft|Core@[7.2,);"
+ "after:BuildCraft|Energy@[7.2,);"
+ "after:ExtrabiomesXL;"
@@ -9,6 +9,7 @@ import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
@@ -39,8 +40,7 @@ public interface IBeekeepingLogic extends INbtWritable, INbtReadable {
/* CLIENT */
/**
* Call this when the housing comes into view of the client.
* (i.e. when {@link TileEntity#getUpdateTag()} is called)
* Sync to client by using {@link #writeToNBT(NBTTagCompound)} in your {@link TileEntity#getUpdateTag()}
*/
void syncToClient();
@@ -11,6 +11,8 @@ public interface IHiveTile {
*/
void calmBees();
boolean isAngry();
/**
* Called when the hive is attacked.
*/
@@ -17,14 +17,14 @@ public interface IHiveRegistry {
/* Forestry Hive Names */
enum HiveType implements IStringSerializable {
FOREST("Forestry:forest", "Forestry.speciesForest"),
MEADOWS("Forestry:meadows", "Forestry.speciesMeadows"),
DESERT("Forestry:desert", "Forestry.speciesModest"),
JUNGLE("Forestry:jungle", "Forestry.speciesTropical"),
END("Forestry:end", "Forestry.speciesEnded"),
SNOW("Forestry:snow", "Forestry.speciesWintry"),
SWAMP("Forestry:swamp", "Forestry.speciesMarshy"),
SWARM("Forestry:swarm", "Forestry.speciesForest");
FOREST("forestry:forest", "forestry.speciesForest"),
MEADOWS("forestry:meadows", "forestry.speciesMeadows"),
DESERT("forestry:desert", "forestry.speciesModest"),
JUNGLE("forestry:jungle", "forestry.speciesTropical"),
END("forestry:end", "forestry.speciesEnded"),
SNOW("forestry:snow", "forestry.speciesWintry"),
SWAMP("forestry:swamp", "forestry.speciesMarshy"),
SWARM("forestry:swarm", "forestry.speciesForest");
public static final HiveType[] VALUES = values();
@@ -6,7 +6,7 @@
package forestry.api.greenhouse;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
@@ -22,7 +22,7 @@ public interface IGreenhouseState {
float getExactHumidity();
List<IInternalBlock> getInternalBlocks();
Set<IInternalBlock> getInternalBlocks();
Collection<IMultiblockComponent> getGreenhouseComponents();
@@ -14,7 +14,6 @@ import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -23,7 +22,6 @@ import java.util.Random;
import java.util.Set;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.BlockRedFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
@@ -71,7 +69,6 @@ import forestry.apiculture.blocks.BlockRegistryApiculture;
import forestry.apiculture.commands.CommandBee;
import forestry.apiculture.entities.EntityMinecartApiary;
import forestry.apiculture.entities.EntityMinecartBeehouse;
import forestry.apiculture.entities.ParticleBee;
import forestry.apiculture.flowers.FlowerRegistry;
import forestry.apiculture.genetics.BeeBranchDefinition;
import forestry.apiculture.genetics.BeeDefinition;
@@ -95,6 +92,7 @@ import forestry.apiculture.multiblock.TileAlvearyStabiliser;
import forestry.apiculture.multiblock.TileAlvearySwarmer;
import forestry.apiculture.network.PacketRegistryApiculture;
import forestry.apiculture.proxy.ProxyApiculture;
import forestry.apiculture.proxy.ProxyApicultureClient;
import forestry.apiculture.tiles.TileCandle;
import forestry.apiculture.tiles.TileHive;
import forestry.apiculture.worldgen.HiveDecorator;
@@ -850,7 +848,7 @@ public class PluginApiculture extends BlankForestryPlugin {
for (int i = 0; i < ParticleSnow.sprites.length; i++) {
ParticleSnow.sprites[i] = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/snow." + (i + 1)));
}
ParticleBee.beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
ProxyApicultureClient.beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
}
private static class EndFlowerAcceptableRule implements IFlowerAcceptableRule {
@@ -33,12 +33,8 @@ public enum BlockTypeApicultureTesr implements IBlockTypeTesr {
@Nonnull
private final IMachinePropertiesTesr<?> machineProperties;
<T extends TileForestry> BlockTypeApicultureTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nullable AxisAlignedBB boundingBox) {
if (boundingBox != null) {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
} else {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0");
}
<T extends TileForestry> BlockTypeApicultureTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, AxisAlignedBB boundingBox) {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
}
@Nonnull
@@ -0,0 +1,130 @@
/*******************************************************************************
* 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.apiculture.entities;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import forestry.apiculture.proxy.ProxyApicultureClient;
public class ParticleBeeExplore extends Particle {
private final Vec3d origin;
public ParticleBeeExplore(World world, Vec3d origin, BlockPos destination, int color) {
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
setParticleTexture(ProxyApicultureClient.beeSprite);
this.origin = origin;
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.015;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.015;
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.015;
particleRed = (color >> 16 & 255) / 255.0F;
particleGreen = (color >> 8 & 255) / 255.0F;
particleBlue = (color & 255) / 255.0F;
this.setSize(0.1F, 0.1F);
this.particleScale *= 0.2F;
this.particleMaxAge = (int) (80.0D / (Math.random() * 0.8D + 0.2D));
this.motionX *= 0.9D;
this.motionY *= 0.015D;
this.motionZ *= 0.9D;
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge < this.particleMaxAge * 0.25) {
// venture out
this.motionX *= 0.92 + 0.3D * rand.nextFloat();
this.motionY = (this.motionY + 0.3 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.92 + 0.3D * rand.nextFloat();
} else if (this.particleAge < this.particleMaxAge * 0.5) {
// slow down
this.motionX *= 0.75 + 0.3D * rand.nextFloat();
this.motionY = (this.motionY + 0.3 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.75 + 0.3D * rand.nextFloat();
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.95;
} else {
// get to origin
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
this.setExpired();
}
}
@Override
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float minU = 0;
float maxU = 1;
float minV = 0;
float maxV = 1;
if (this.particleTexture != null) {
minU = particleTexture.getMinU();
maxU = particleTexture.getMaxU();
minV = particleTexture.getMinV();
maxV = particleTexture.getMaxV();
}
float f10 = 0.1F * particleScale;
float f11 = (float) (prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
float f12 = (float) (prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
float f13 = (float) (prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);
int i = this.getBrightnessForRender(partialTicks);
int j = i >> 16 & 65535;
int k = i & 65535;
worldRendererIn.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
}
// avoid calculating lighting for bees, it is too much processing
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 15728880;
}
@Override
public int getFXLayer() {
return 1;
}
}
@@ -12,30 +12,26 @@ package forestry.apiculture.entities;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class ParticleBee extends Particle {
private final double originX;
private final double originY;
private final double originZ;
private final BlockPos destination;
public static TextureAtlasSprite beeSprite;
import forestry.apiculture.proxy.ProxyApicultureClient;
public ParticleBee(World world, double x, double y, double z, int color, BlockPos destination) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
setParticleTexture(beeSprite);
this.originX = x;
this.originY = y;
this.originZ = z;
public class ParticleBeeRoundTrip extends Particle {
private final Vec3d origin;
private final BlockPos destination;
public ParticleBeeRoundTrip(World world, Vec3d origin, BlockPos destination, int color) {
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
setParticleTexture(ProxyApicultureClient.beeSprite);
this.origin = origin;
this.destination = destination;
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.015;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.015;
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.015;
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.02 + 0.1 * rand.nextFloat();
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.015 + 0.1 * rand.nextFloat();
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.02 + 0.1 * rand.nextFloat();
particleRed = (color >> 16 & 255) / 255.0F;
particleGreen = (color >> 8 & 255) / 255.0F;
@@ -61,34 +57,34 @@ public class ParticleBee extends Particle {
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (this.originX - this.posX) * 0.03;
this.motionY = (this.originY - this.posY) * 0.03;
this.motionZ = (this.originZ - this.posZ) * 0.03;
this.motionX = (origin.xCoord - this.posX) * 0.03 + 0.1 * rand.nextFloat();
this.motionY = (origin.yCoord - this.posY) * 0.03 + 0.1 * rand.nextFloat();
this.motionZ = (origin.zCoord - this.posZ) * 0.03 + 0.1 * rand.nextFloat();
}
if (this.particleAge < this.particleMaxAge * 0.25) {
// venture out
this.motionX *= 0.92 + 0.2D * rand.nextFloat();
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionY = (this.motionY + 0.3 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.92 + 0.2D * rand.nextFloat();
} else if (this.particleAge < this.particleMaxAge * 0.5) {
// get to flower destination
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.03;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.03;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.1;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.03;
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (this.originY - this.posY) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.95;
} else {
// get to origin
this.motionX = (this.originX - this.posX) * 0.03;
this.motionY = (this.originY - this.posY) * 0.03;
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (this.originZ - this.posZ) * 0.03;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
@@ -124,11 +120,10 @@ public class ParticleBee extends Particle {
worldRendererIn.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
}
// avoid calculating collisions for bees, it is too much processing
// avoid calculating lighting for bees, it is too much processing
@Override
public void moveEntity(double x, double y, double z) {
this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
this.resetPositionToBB();
public int getBrightnessForRender(float p_189214_1_) {
return 15728880;
}
@Override
@@ -0,0 +1,137 @@
/*******************************************************************************
* 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.apiculture.entities;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import forestry.apiculture.proxy.ProxyApicultureClient;
public class ParticleBeeTargetEntity extends Particle {
private final Vec3d origin;
private final Entity entity;
public ParticleBeeTargetEntity(World world, Vec3d origin, Entity entity, int color) {
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
setParticleTexture(ProxyApicultureClient.beeSprite);
this.origin = origin;
this.entity = entity;
this.motionX = (entity.posX - this.posX) * 0.015;
this.motionY = (entity.posY + 1.62F - this.posY) * 0.015;
this.motionZ = (entity.posZ - this.posZ) * 0.015;
particleRed = (color >> 16 & 255) / 255.0F;
particleGreen = (color >> 8 & 255) / 255.0F;
particleBlue = (color & 255) / 255.0F;
this.setSize(0.1F, 0.1F);
this.particleScale *= 0.2F;
this.particleMaxAge = (int) (80.0D / (Math.random() * 0.8D + 0.2D));
this.motionX *= 0.9D;
this.motionY *= 0.9D;
this.motionZ *= 0.9D;
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge < this.particleMaxAge * 0.5) {
// fly near the entity
this.motionX = (entity.posX - this.posX) * 0.09;
this.motionX = (this.motionX + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionY = (entity.posY + 1.62F - this.posY) * 0.03;
this.motionY = (this.motionY + 0.4 * (-0.5 + rand.nextFloat())) / 4;
this.motionZ = (entity.posZ - this.posZ) * 0.09;
this.motionZ = (this.motionZ + 0.2 * (-0.5 + rand.nextFloat())) / 2;
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.95;
} else {
// get to origin
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
this.setExpired();
}
}
@Override
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float minU = 0;
float maxU = 1;
float minV = 0;
float maxV = 1;
if (this.particleTexture != null) {
minU = particleTexture.getMinU();
maxU = particleTexture.getMaxU();
minV = particleTexture.getMinV();
maxV = particleTexture.getMaxV();
}
float f10 = 0.1F * particleScale;
float f11 = (float) (prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
float f12 = (float) (prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
float f13 = (float) (prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);
int i = this.getBrightnessForRender(partialTicks);
int j = i >> 16 & 65535;
int k = i & 65535;
worldRendererIn.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
}
// avoid calculating lighting for bees, it is too much processing
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 15728880;
}
// avoid calculating collisions
@Override
public void moveEntity(double x, double y, double z) {
this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
@Override
public int getFXLayer() {
return 1;
}
}
@@ -17,7 +17,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.init.MobEffects;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import forestry.api.apiculture.BeeManager;
@@ -105,16 +104,14 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
@Override
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
Vec3d origin = housing.getBeeFXCoordinates();
IBeekeepingLogic beekeepingLogic = housing.getBeekeepingLogic();
List<BlockPos> flowerPositions = beekeepingLogic.getFlowerPositions();
int beeColor = genome.getPrimary().getSpriteColour(0);
Proxies.render.addBeeHiveFX(housing.getWorldObj(), origin.xCoord, origin.yCoord, origin.zCoord, beeColor, flowerPositions);
Proxies.render.addBeeHiveFX(housing, genome, flowerPositions);
return storedData;
}
protected Vec3i getModifiedArea(IBeeGenome genome, IBeeHousing housing) {
public static Vec3i getModifiedArea(IBeeGenome genome, IBeeHousing housing) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1f);
@@ -317,12 +317,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public void formatDescriptionPacket(NBTTagCompound data) {
writeToNBT(data);
beekeepingLogic.syncToClient();
beekeepingLogic.writeToNBT(data);
}
@Override
public void decodeDescriptionPacket(NBTTagCompound data) {
readFromNBT(data);
beekeepingLogic.readFromNBT(data);
}
/* IActivatable */
@@ -10,8 +10,12 @@
******************************************************************************/
package forestry.apiculture.proxy;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
public class ProxyApicultureClient extends ProxyApiculture {
public static TextureAtlasSprite beeSprite;
@Override
public void initializeRendering() {
// TODO: remove unused bee entity model completely
@@ -69,8 +69,15 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
@Nonnull
@Override
public NBTTagCompound getUpdateTag() {
beeLogic.syncToClient();
return super.getUpdateTag();
NBTTagCompound updateTag = super.getUpdateTag();
beeLogic.writeToNBT(updateTag);
return updateTag;
}
@Override
public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
super.handleUpdateTag(tag);
beeLogic.readFromNBT(tag);
}
/* ICLIMATISED */
@@ -21,6 +21,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
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.DamageSource;
@@ -74,7 +75,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
@Nonnull
private final IErrorLogic errorLogic;
private IBee containedBee = null;
private boolean active = true;
private boolean active = false;
private boolean angry = false;
private int calmTime;
@@ -97,7 +98,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
}
if (worldObj.isRemote) {
if (!updatedLight && worldObj.getWorldTime() % 20 == 0) {
if (!updatedLight && worldObj.getWorldTime() % 100 == 0) {
updatedLight = worldObj.checkLightFor(EnumSkyBlock.BLOCK, getPos());
}
if (active && worldObj.rand.nextInt(4) == 0) {
@@ -108,7 +109,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
} else {
boolean canWork = beeLogic.canWork(); // must be called every tick to stay updated
if (worldObj.rand.nextInt(angry ? 10 : 80) == 0) {
if (worldObj.rand.nextInt(angry ? 10 : 200) == 0) {
if (calmTime == 0) {
if (canWork) {
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
@@ -119,19 +120,13 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
attack(entity, 2);
}
beeLogic.doWork();
setActive(true);
} else {
setActive(false);
}
} else {
calmTime--;
if (calmTime == 0) {
setActive(true);
} else {
setActive(false);
}
}
}
setActive(calmTime == 0);
}
}
@@ -203,6 +198,11 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
setActive(false);
}
@Override
public boolean isAngry() {
return angry;
}
@Override
public void onAttack(World world, BlockPos pos, EntityPlayer player) {
if (calmTime == 0) {
@@ -231,8 +231,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
if (damage > 0) {
// Entities are not attacked if they wear a full set of apiarist's armor.
int count = BeeManager.armorApiaristHelper.wearsItems(entity, damageSourceBeeHive.damageType, true);
damage -= damage / 4.0f * count;
if (damage > 0) {
if (entity.worldObj.rand.nextInt(4) >= count) {
entity.attackEntityFrom(damageSourceBeeHive, damage);
}
}
@@ -258,8 +257,30 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
@Nullable
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
beeLogic.syncToClient();
return super.getUpdatePacket();
return new SPacketUpdateTileEntity(pos, 0, getUpdateTag());
}
@Nonnull
@Override
public NBTTagCompound getUpdateTag() {
NBTTagCompound nbt = super.getUpdateTag();
nbt.setBoolean("active", calmTime == 0);
beeLogic.writeToNBT(nbt);
return nbt;
}
@Override
public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
super.handleUpdateTag(tag);
setActive(tag.getBoolean("active"));
beeLogic.readFromNBT(tag);
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
super.onDataPacket(net, pkt);
NBTTagCompound nbt = pkt.getNbtCompound();
handleUpdateTag(nbt);
}
@Override
@@ -16,6 +16,7 @@ import java.util.Collections;
import java.util.Random;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -40,7 +41,7 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
private final EnumForestryWoodType woodType;
public BlockArbDoor(EnumForestryWoodType woodType) {
super(MaterialArbWood.ARB_WOOD);
super(Material.WOOD);
this.woodType = woodType;
setHarvestLevel("axe", 0);
@@ -2,6 +2,7 @@ package forestry.arboriculture.blocks;
import com.google.common.collect.Lists;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
@@ -18,9 +19,11 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -383,35 +386,49 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
@Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ICharcoalPileComponent pile = (ICharcoalPileComponent) tile;
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
if (getPileType() == EnumPileType.ASH) {
if(pile.getTree() != null){
ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, pile.getTree().getGenome().getCarbonization(), pile.getTree().getGenome().getCombustibility());
list.add(charcoal);
list.add(new ItemStack(PluginCore.items.ash, 3));
}else{
list.add(new ItemStack(Blocks.DIRT, 2));
list.add(new ItemStack(PluginCore.items.ash, 2));
}
} else if (getPileType() == EnumPileType.DIRT) {
list.add(new ItemStack(this));
} else {
list.add(createWoodPile(pile.getTree()));
}
drop.set(list);
}
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getActiveItemStack());
drop.set(getPileDrop(world, pos, state, fortune));
}
}
@Nonnull
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> drops = drop.get();
drop.remove();
// not harvested, get drops normally
if (drops == null) {
drops = getPileDrop(world, pos, state, fortune);
}
return drops;
}
@Nonnull
private List<ItemStack> getPileDrop(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ICharcoalPileComponent pile = (ICharcoalPileComponent) tile;
if (getPileType() == EnumPileType.ASH) {
if (pile.getTree() != null) {
ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, pile.getTree().getGenome().getCarbonization(), pile.getTree().getGenome().getCombustibility());
list.add(charcoal);
list.add(new ItemStack(PluginCore.items.ash, 3));
} else {
list.add(new ItemStack(Blocks.DIRT, 2));
list.add(new ItemStack(PluginCore.items.ash, 2));
}
} else if (getPileType() == EnumPileType.DIRT) {
list.add(new ItemStack(this));
} else {
list.add(createWoodPile(pile.getTree()));
}
}
return list;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
@@ -73,14 +73,16 @@ public class ItemBlockPile<B extends Block> extends ItemBlockForestry<Block> {
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
if(block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)){
if (block.hasTileEntity(newState)) {
if (stack.hasTagCompound()) {
TilePile tile = TileUtil.getTile(world, pos, TilePile.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
tile.markDirty();
if (placed) {
if (block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)) {
if (block.hasTileEntity(newState)) {
if (stack.hasTagCompound()) {
TilePile tile = TileUtil.getTile(world, pos, TilePile.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
tile.markDirty();
}
}
}
}
@@ -92,14 +92,14 @@ public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
// Render the plain leaf block.
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, leafSprite, 0);
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leafSprite, 0);
// Render overlay for fruit leaves.
ResourceLocation fruitSpriteLocation = tile.getFruitSprite();
if (fruitSpriteLocation != null) {
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, fruitSprite, 1);
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitSprite, 1);
}
// Set the particle sprite
@@ -124,6 +124,14 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
return definition.getBoundingBox(pos, blockState);
}
@Nonnull
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) {
IMachineProperties definition = getDefinition();
return definition.getBoundingBox(pos, state).offset(pos);
}
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
IMachineProperties definition = getDefinition();
@@ -58,18 +58,20 @@ public class ItemBlockForestry<B extends Block> extends ItemBlock {
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
if (block.hasTileEntity(newState)) {
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
if (placed) {
if (block.hasTileEntity(newState)) {
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
}
}
}
}
if (block instanceof BlockBase) {
((BlockBase) block).rotateAfterPlacement(player, world, pos, side);
if (block instanceof BlockBase) {
((BlockBase) block).rotateAfterPlacement(player, world, pos, side);
}
}
return placed;
@@ -23,11 +23,14 @@ import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraftforge.common.animation.ITimeValue;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.core.fluids.Fluids;
import forestry.core.models.BlockModelIndex;
import forestry.core.models.ModelIndex;
@@ -115,7 +118,7 @@ public class ProxyRender {
/* FX */
public void addBeeHiveFX(@Nonnull World world, double x, double y, double z, int color, @Nonnull List<BlockPos> flowerPositions) {
public void addBeeHiveFX(@Nonnull IBeeHousing housing, @Nonnull IBeeGenome genome, @Nonnull List<BlockPos> flowerPositions) {
}
public void addEntityHoneyDustFX(World world, double x, double y, double z) {
@@ -28,11 +28,14 @@ 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;
@@ -40,7 +43,13 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.animation.ITimeValue;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import forestry.apiculture.entities.ParticleBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IHiveTile;
import forestry.apiculture.entities.ParticleBeeExplore;
import forestry.apiculture.entities.ParticleBeeRoundTrip;
import forestry.apiculture.entities.ParticleBeeTargetEntity;
import forestry.apiculture.genetics.alleles.AlleleEffect;
import forestry.apiculture.render.TextureHabitatLocator;
import forestry.core.config.Config;
import forestry.core.config.Constants;
@@ -62,6 +71,7 @@ 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;
public class ProxyRenderClient extends ProxyRender {
@@ -188,16 +198,52 @@ public class ProxyRenderClient extends ProxyRender {
}
@Override
public void addBeeHiveFX(@Nonnull World world, double x, double y, double z, int color, @Nonnull List<BlockPos> flowerPositions) {
public void addBeeHiveFX(@Nonnull IBeeHousing housing, @Nonnull IBeeGenome genome, @Nonnull List<BlockPos> flowerPositions) {
World world = housing.getWorldObj();
if (!shouldSpawnParticle(world)) {
return;
}
ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer;
Vec3d particleStart = housing.getBeeFXCoordinates();
// Avoid rendering bee particles that are too far away, they're very small.
// At 32+ distance, have no bee particles. Make more particles up close.
BlockPos playerPosition = Proxies.common.getPlayer().getPosition();
double playerDistanceSq = playerPosition.distanceSqToCenter(particleStart.xCoord, particleStart.yCoord, particleStart.zCoord);
if (world.rand.nextInt(1024) < playerDistanceSq) {
return;
}
int color = genome.getPrimary().getSpriteColour(0);
if (!flowerPositions.isEmpty()) {
BlockPos destination = flowerPositions.get(world.rand.nextInt(flowerPositions.size()));
Particle particle = new ParticleBee(world, x, y, z, color, destination);
ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer;
effectRenderer.addEffect(particle);
int randomInt = world.rand.nextInt(100);
if (housing instanceof IHiveTile) {
if (((IHiveTile) housing).isAngry() || randomInt >= 85) {
List<EntityLivingBase> entitiesInRange = AlleleEffect.getEntitiesInRange(genome, housing, EntityLivingBase.class);
if (!entitiesInRange.isEmpty()) {
EntityLivingBase entity = entitiesInRange.get(world.rand.nextInt(entitiesInRange.size()));
Particle particle = new ParticleBeeTargetEntity(world, particleStart, entity, color);
effectRenderer.addEffect(particle);
return;
}
}
}
if (randomInt < 75) {
BlockPos destination = flowerPositions.get(world.rand.nextInt(flowerPositions.size()));
Particle particle = new ParticleBeeRoundTrip(world, particleStart, destination, color);
effectRenderer.addEffect(particle);
} else {
Vec3i area = AlleleEffect.getModifiedArea(genome, housing);
Vec3i offset = housing.getCoordinates().add(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
BlockPos destination = VectUtil.getRandomPositionInArea(world.rand, area).add(offset);
Particle particle = new ParticleBeeExplore(world, particleStart, destination, color);
effectRenderer.addEffect(particle);
}
}
}
@@ -100,7 +100,7 @@ public final class VectUtil {
do {
pos = nextPos();
}
while (pos != null && (pos.getX() > maxPos.getX() || pos.getZ() > maxPos.getZ() || pos.getX() < minPos.getX() || pos.getZ() < minPos.getZ()));
while (pos != null && (pos.getX() > maxPos.getX() || pos.getY() > maxPos.getY() || pos.getZ() > maxPos.getZ() || pos.getX() < minPos.getX() || pos.getY() < minPos.getY() || pos.getZ() < minPos.getZ()));
return pos;
}
@@ -12,7 +12,7 @@ package forestry.greenhouse;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
@@ -45,8 +45,8 @@ public class FakeGreenhouseState implements IGreenhouseState {
}
@Override
public List<IInternalBlock> getInternalBlocks() {
return Collections.emptyList();
public Set<IInternalBlock> getInternalBlocks() {
return Collections.emptySet();
}
@Override
@@ -19,6 +19,7 @@ import forestry.api.greenhouse.IInternalBlock;
import forestry.core.multiblock.IMultiblockControllerInternal;
import forestry.core.multiblock.MultiblockRegistry;
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
import forestry.greenhouse.multiblock.InternalBlockCheck;
public class GreenhouseHelper implements IGreenhouseHelper {
@@ -28,7 +29,7 @@ public class GreenhouseHelper implements IGreenhouseHelper {
for (IMultiblockControllerInternal controllerInternal : MultiblockRegistry.getControllersFromWorld(world)) {
if (controllerInternal instanceof IGreenhouseControllerInternal) {
if (controllerInternal.isAssembled()) {
if (isPosiotionInGreenhouse((IGreenhouseControllerInternal) controllerInternal, pos)) {
if (isPositionInGreenhouse((IGreenhouseControllerInternal) controllerInternal, pos)) {
return ((IGreenhouseControllerInternal) controllerInternal).createState();
}
}
@@ -38,13 +39,9 @@ public class GreenhouseHelper implements IGreenhouseHelper {
return null;
}
private static boolean isPosiotionInGreenhouse(IGreenhouseControllerInternal controller, BlockPos pos) {
for (IInternalBlock internalBlock : controller.getInternalBlocks()) {
if (internalBlock.getPos().equals(pos)) {
return true;
}
}
return false;
private static boolean isPositionInGreenhouse(IGreenhouseControllerInternal controller, BlockPos pos) {
IInternalBlock checkBlock = new InternalBlockCheck(pos);
return controller.getInternalBlocks().contains(checkBlock);
}
}
@@ -11,7 +11,7 @@
package forestry.greenhouse;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
@@ -24,10 +24,10 @@ public final class GreenhouseState implements IGreenhouseState {
private final float humidity;
private final float temperature;
private final List<IInternalBlock> internalBlocks;
private final Set<IInternalBlock> internalBlocks;
private final Collection<IMultiblockComponent> greenhouseComponents;
public GreenhouseState(float humidity, float temperature, List<IInternalBlock> internalBlocks, Collection<IMultiblockComponent> greenhouseComponents) {
public GreenhouseState(float humidity, float temperature, Set<IInternalBlock> internalBlocks, Collection<IMultiblockComponent> greenhouseComponents) {
this.humidity = humidity;
this.temperature = temperature;
this.internalBlocks = internalBlocks;
@@ -59,7 +59,7 @@ public final class GreenhouseState implements IGreenhouseState {
}
@Override
public List<IInternalBlock> getInternalBlocks() {
public Set<IInternalBlock> getInternalBlocks() {
return internalBlocks;
}
@@ -13,6 +13,7 @@ package forestry.greenhouse.multiblock;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
@@ -97,8 +98,8 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
}
@Override
public List<IInternalBlock> getInternalBlocks() {
return Collections.emptyList();
public Set<IInternalBlock> getInternalBlocks() {
return Collections.emptySet();
}
@Override
@@ -64,6 +64,7 @@ import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.ILiquidTankTile;
import forestry.core.utils.CamouflageUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Log;
import forestry.core.utils.Translator;
import forestry.energy.EnergyManager;
@@ -76,7 +77,7 @@ import forestry.greenhouse.tiles.TileGreenhouseSprinkler;
public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, ILiquidTankTile {
private final List<IInternalBlock> internalBlocks = new ArrayList<>();
private final Set<IInternalBlock> internalBlocks = new HashSet<>();
private final Set<IGreenhouseComponent.Listener> listenerComponents = new HashSet<>();
private final Set<IGreenhouseComponent.Climatiser> climatiserComponents = new HashSet<>();
private final Set<IGreenhouseComponent.Active> activeComponents = new HashSet<>();
@@ -288,35 +289,52 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
/* CAMOUFLAGE */
@Override
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
ItemStack oldCamouflageBlock;
switch (type) {
case DEFAULT:
camouflagePlainBlock = camouflageBlock;
break;
case GLASS:
camouflageGlassBlock = camouflageBlock;
break;
case DOOR:
camouflageDoorBlock = camouflageBlock;
break;
default:
return;
case DEFAULT:
oldCamouflageBlock = camouflagePlainBlock;
break;
case GLASS:
oldCamouflageBlock = camouflageGlassBlock;
break;
case DOOR:
oldCamouflageBlock = camouflageDoorBlock;
break;
default:
return;
}
if (worldObj != null) {
if (worldObj.isRemote) {
for (IMultiblockComponent comp : connectedParts) {
if (comp instanceof ICamouflagedTile) {
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
if (camBlock.getCamouflageType() == type) {
worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, oldCamouflageBlock)){
switch (type) {
case DEFAULT:
camouflagePlainBlock = camouflageBlock;
break;
case GLASS:
camouflageGlassBlock = camouflageBlock;
break;
case DOOR:
camouflageDoorBlock = camouflageBlock;
break;
default:
return;
}
if (worldObj != null) {
if (worldObj.isRemote) {
for (IMultiblockComponent comp : connectedParts) {
if (comp instanceof ICamouflagedTile) {
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
if (camBlock.getCamouflageType() == type) {
worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
}
}
}
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
}
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
}
@Override
@@ -515,10 +533,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
int minX = getSizeLimits().getMinimumXSize();
int minY = getSizeLimits().getMinimumYSize();
int minZ = getSizeLimits().getMinimumZSize();
if (connectedParts.size() < getSizeLimits().getMinimumNumberOfBlocksForAssembledMachine()) {
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small", minX, minY, minZ));
}
BlockPos maximumCoord = getMaximumCoord();
BlockPos minimumCoord = getMinimumCoord();
@@ -551,6 +565,10 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.small.z", minZ));
}
if (connectedParts.size() < getSizeLimits().getMinimumNumberOfBlocksForAssembledMachine()) {
throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.greenhouse.error.space.closed", minX, minY, minZ));
}
// Now we run a simple check on each block within that volume.
// Any block deviating = NO DEAL SIR
TileEntity te;
@@ -726,7 +744,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
}
@Override
public List<IInternalBlock> getInternalBlocks() {
public Set<IInternalBlock> getInternalBlocks() {
return internalBlocks;
}
@@ -21,7 +21,7 @@ class GreenhouseMultiblockSizeLimits implements IMultiblockSizeLimits {
@Override
public int getMinimumNumberOfBlocksForAssembledMachine() {
return 5 * 5 * 5 - 36;
return (5 * 5 * 5) - (3 * 3 * 3);
}
@Override
@@ -12,7 +12,7 @@ package forestry.greenhouse.multiblock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
import forestry.api.greenhouse.IGreenhouseState;
import forestry.api.greenhouse.IInternalBlock;
@@ -53,7 +53,7 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM
IGreenhouseState createState();
/**
* @return A list with all internal block's of the greenhouse.
* @return All internal blocks of the greenhouse.
*/
List<IInternalBlock> getInternalBlocks();
Set<IInternalBlock> getInternalBlocks();
}
@@ -74,4 +74,9 @@ public class InternalBlock implements IInternalBlock {
IInternalBlock internalBlock = (IInternalBlock) obj;
return internalBlock.getPos().equals(getPos());
}
@Override
public int hashCode() {
return pos.hashCode();
}
}
@@ -0,0 +1,54 @@
package forestry.greenhouse.multiblock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import net.minecraft.util.math.BlockPos;
import forestry.api.greenhouse.IInternalBlock;
import forestry.api.greenhouse.IInternalBlockFace;
/**
* Used to check if a blockPos is in a collection of IInternalBlock
*/
public class InternalBlockCheck implements IInternalBlock {
private final BlockPos pos;
public InternalBlockCheck(BlockPos pos) {
this.pos = pos;
}
@Nonnull
@Override
public BlockPos getPos() {
return pos;
}
@Nullable
@Override
public IInternalBlock getRoot() {
return null;
}
@Nonnull
@Override
public Collection<IInternalBlockFace> getFaces() {
return Collections.emptyList();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof IInternalBlock)) {
return false;
}
IInternalBlock internalBlock = (IInternalBlock) obj;
return internalBlock.getPos().equals(getPos());
}
@Override
public int hashCode() {
return pos.hashCode();
}
}
@@ -41,6 +41,7 @@ import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamableGui;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.ITitled;
import forestry.core.utils.ItemStackUtil;
import forestry.greenhouse.blocks.BlockGreenhouse;
import forestry.greenhouse.blocks.BlockGreenhouseType;
import forestry.greenhouse.gui.ContainerGreenhouse;
@@ -93,15 +94,17 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
@Override
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
}
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
@Override
@@ -42,7 +42,7 @@ public class TileGreenhouseControl extends TileGreenhouse implements IGreenhouse
@Override
public <G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork) {
return canWork && hasRedstoneSignal();
return canWork && !hasRedstoneSignal();
}
private boolean hasRedstoneSignal() {
@@ -47,6 +47,7 @@ import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.PlayerUtil;
import forestry.greenhouse.blocks.BlockGreenhouse;
import forestry.greenhouse.blocks.BlockGreenhouseType;
@@ -140,15 +141,17 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
/* CONSTRUCTION MATERIAL */
@Override
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
}
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
@Override