Compare commits

...
11 Commits
18 changed files with 457 additions and 100 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.1940
mcp_mappings=snapshot_20160525
jei_version=3.4.0.+
version_major=5
version_minor=0
version_patch=3
version_patch=4
+1 -1
Submodule lang updated: 53d7c93f90...0e7f1e47f1.
@@ -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();
@@ -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;
@@ -130,6 +127,7 @@ public class PluginApiculture extends BlankForestryPlugin {
public static ProxyApiculture proxy;
private static final String CONFIG_CATEGORY = "apiculture";
public static String beekeepingMode = "NORMAL";
public static TextureAtlasSprite beeSprite;
private static float secondPrincessChance = 0;
public static final int ticksPerBeeWorkCycle = 550;
public static boolean fancyRenderedBees = false;
@@ -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"));
beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
}
private static class EndFlowerAcceptableRule implements IFlowerAcceptableRule {
@@ -0,0 +1,131 @@
/*******************************************************************************
* 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.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;
import forestry.apiculture.PluginApiculture;
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(PluginApiculture.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.PluginApiculture;
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(PluginApiculture.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,138 @@
/*******************************************************************************
* 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.PluginApiculture;
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(PluginApiculture.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 */
@@ -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) {
@@ -258,8 +258,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
@@ -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) {
@@ -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);
}
}
}
@@ -515,10 +515,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 +547,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;
@@ -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