mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Fix whitespace
This commit is contained in:
parent
37e9c17940
commit
344b61e26c
2 changed files with 325 additions and 325 deletions
|
@ -60,11 +60,11 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
public class EntityCloud extends EntityFlying implements IAnimals {
|
public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
private static final DataParameter<Integer> RAINTIMER = EntityDataManager.createKey(EntityCloud.class, DataSerializers.VARINT);
|
private static final DataParameter<Integer> RAINTIMER = EntityDataManager.createKey(EntityCloud.class, DataSerializers.VARINT);
|
||||||
private static final DataParameter<Boolean> THUNDERING = EntityDataManager.createKey(EntityCloud.class, DataSerializers.BOOLEAN);
|
private static final DataParameter<Boolean> THUNDERING = EntityDataManager.createKey(EntityCloud.class, DataSerializers.BOOLEAN);
|
||||||
private static final DataParameter<Integer> SCALE = EntityDataManager.createKey(EntityCloud.class, DataSerializers.VARINT);
|
private static final DataParameter<Integer> SCALE = EntityDataManager.createKey(EntityCloud.class, DataSerializers.VARINT);
|
||||||
|
|
||||||
private static final DataParameter<Boolean> STATIONARY = EntityDataManager.createKey(EntityCloud.class, DataSerializers.BOOLEAN);
|
private static final DataParameter<Boolean> STATIONARY = EntityDataManager.createKey(EntityCloud.class, DataSerializers.BOOLEAN);
|
||||||
|
|
||||||
protected double targetAltitude;
|
protected double targetAltitude;
|
||||||
|
|
||||||
|
@ -74,13 +74,13 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
private final double baseWidth = 3f;
|
private final double baseWidth = 3f;
|
||||||
private final double baseHeight = 0.8f;
|
private final double baseHeight = 0.8f;
|
||||||
|
|
||||||
public EntityCloud(World world) {
|
public EntityCloud(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
ignoreFrustumCheck = true;
|
ignoreFrustumCheck = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void entityInit() {
|
protected void entityInit() {
|
||||||
super.entityInit();
|
super.entityInit();
|
||||||
dataManager.register(RAINTIMER, 0);
|
dataManager.register(RAINTIMER, 0);
|
||||||
dataManager.register(THUNDERING, false);
|
dataManager.register(THUNDERING, false);
|
||||||
|
@ -88,43 +88,43 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
dataManager.register(SCALE, 1);
|
dataManager.register(SCALE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEvent getHurtSound(DamageSource damageSource) {
|
protected SoundEvent getHurtSound(DamageSource damageSource) {
|
||||||
return SoundEvents.BLOCK_CLOTH_HIT;
|
return SoundEvents.BLOCK_CLOTH_HIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEvent getDeathSound() {
|
protected SoundEvent getDeathSound() {
|
||||||
return SoundEvents.BLOCK_CLOTH_STEP;
|
return SoundEvents.BLOCK_CLOTH_STEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item getDropItem() {
|
protected Item getDropItem() {
|
||||||
return UItems.cloud_matter;
|
return UItems.cloud_matter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canTriggerWalking() {
|
protected boolean canTriggerWalking() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesEntityNotTriggerPressurePlate() {
|
public boolean doesEntityNotTriggerPressurePlate() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRenderOnFire() {
|
public boolean canRenderOnFire() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the render brightness of this entity based on the surrounding world light values.
|
* Gets the render brightness of this entity based on the surrounding world light values.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getBrightnessForRender() {
|
public int getBrightnessForRender() {
|
||||||
return 0xF00000;
|
return 0xF00000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the brightness percentage for this entity based on the surrounding world light values.
|
* Gets the brightness percentage for this entity based on the surrounding world light values.
|
||||||
|
@ -135,14 +135,14 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canDespawn() {
|
protected boolean canDespawn() {
|
||||||
return !hasCustomName() && !getStationary() && !getOpaque();
|
return !hasCustomName() && !getStationary() && !getOpaque();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxSpawnedInChunk() {
|
public int getMaxSpawnedInChunk() {
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStruckByLightning(EntityLightningBolt lightningBolt) {
|
public void onStruckByLightning(EntityLightningBolt lightningBolt) {
|
||||||
|
@ -165,115 +165,115 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void collideWithEntity(Entity other) {
|
protected void collideWithEntity(Entity other) {
|
||||||
if (other instanceof EntityCloud) {
|
if (other instanceof EntityCloud) {
|
||||||
super.collideWithEntity(other);
|
super.collideWithEntity(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyEntityCollision(Entity other) {
|
public void applyEntityCollision(Entity other) {
|
||||||
if (other instanceof EntityPlayer) {
|
if (other instanceof EntityPlayer) {
|
||||||
if (Predicates.INTERACT_WITH_CLOUDS.test((EntityPlayer)other)) {
|
if (Predicates.INTERACT_WITH_CLOUDS.test((EntityPlayer)other)) {
|
||||||
super.applyEntityCollision(other);
|
super.applyEntityCollision(other);
|
||||||
}
|
}
|
||||||
} else if (other instanceof EntityCloud) {
|
} else if (other instanceof EntityCloud) {
|
||||||
super.applyEntityCollision(other);
|
super.applyEntityCollision(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double randomIn(Random rand, double min, double max) {
|
public static double randomIn(Random rand, double min, double max) {
|
||||||
return ((max - min) * rand.nextFloat());
|
return ((max - min) * rand.nextFloat());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
AxisAlignedBB boundingbox = getEntityBoundingBox();
|
AxisAlignedBB boundingbox = getEntityBoundingBox();
|
||||||
|
|
||||||
if (getIsRaining()) {
|
if (getIsRaining()) {
|
||||||
if (world.isRemote) {
|
if (world.isRemote) {
|
||||||
for (int i = 0; i < 30 * getCloudSize(); i++) {
|
for (int i = 0; i < 30 * getCloudSize(); i++) {
|
||||||
double x = posX + randomIn(rand, boundingbox.minX, boundingbox.maxX) - width / 2;
|
double x = posX + randomIn(rand, boundingbox.minX, boundingbox.maxX) - width / 2;
|
||||||
double y = getEntityBoundingBox().minY + height/2;
|
double y = getEntityBoundingBox().minY + height/2;
|
||||||
double z = posZ + randomIn(rand, boundingbox.minX, boundingbox.maxX) - width / 2;
|
double z = posZ + randomIn(rand, boundingbox.minX, boundingbox.maxX) - width / 2;
|
||||||
|
|
||||||
int particleId = canSnowHere(new BlockPos(x, y, z)) ? EnumParticleTypes.SNOW_SHOVEL.getParticleID() : UParticles.RAIN_PARTICLE;
|
int particleId = canSnowHere(new BlockPos(x, y, z)) ? EnumParticleTypes.SNOW_SHOVEL.getParticleID() : UParticles.RAIN_PARTICLE;
|
||||||
|
|
||||||
Particles.instance().spawnParticle(particleId, false, x, y, z, 0, 0, 0);
|
Particles.instance().spawnParticle(particleId, false, x, y, z, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisAlignedBB rainedArea = boundingbox
|
AxisAlignedBB rainedArea = boundingbox
|
||||||
.expand(1, 0, 1)
|
.expand(1, 0, 1)
|
||||||
.expand(0, -(posY - getGroundPosition(posX, posZ).getY()), 0);
|
.expand(0, -(posY - getGroundPosition(posX, posZ).getY()), 0);
|
||||||
|
|
||||||
for (EntityPlayer j : world.getEntitiesWithinAABB(EntityPlayer.class, rainedArea)) {
|
for (EntityPlayer j : world.getEntitiesWithinAABB(EntityPlayer.class, rainedArea)) {
|
||||||
j.world.playSound(j, j.getPosition(), SoundEvents.WEATHER_RAIN, SoundCategory.AMBIENT, 0.1F, 0.6F);
|
j.world.playSound(j, j.getPosition(), SoundEvents.WEATHER_RAIN, SoundCategory.AMBIENT, 0.1F, 0.6F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos pos = getGroundPosition(
|
BlockPos pos = getGroundPosition(
|
||||||
posX + rand.nextFloat() * width,
|
posX + rand.nextFloat() * width,
|
||||||
posZ + rand.nextFloat() * width
|
posZ + rand.nextFloat() * width
|
||||||
);
|
);
|
||||||
|
|
||||||
if (getIsThundering()) {
|
if (getIsThundering()) {
|
||||||
if (rand.nextInt(3000) == 0) {
|
if (rand.nextInt(3000) == 0) {
|
||||||
spawnThunderbolt(pos);
|
spawnThunderbolt(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rand.nextInt(200) == 0) {
|
if (rand.nextInt(200) == 0) {
|
||||||
setIsThundering(false);
|
setIsThundering(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
if (state.getBlock() instanceof BlockFire) {
|
if (state.getBlock() instanceof BlockFire) {
|
||||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rand.nextInt(20) == 0) {
|
if (rand.nextInt(20) == 0) {
|
||||||
BlockPos below = pos.down();
|
BlockPos below = pos.down();
|
||||||
state = world.getBlockState(below);
|
state = world.getBlockState(below);
|
||||||
if (state.getBlock() != null) {
|
if (state.getBlock() != null) {
|
||||||
if (world.canBlockFreezeWater(below)) {
|
if (world.canBlockFreezeWater(below)) {
|
||||||
world.setBlockState(below, Blocks.ICE.getDefaultState());
|
world.setBlockState(below, Blocks.ICE.getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.canSnowAt(pos, false)) {
|
if (world.canSnowAt(pos, false)) {
|
||||||
world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
|
world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.getBlock() instanceof BlockFarmland) {
|
if (state.getBlock() instanceof BlockFarmland) {
|
||||||
int moisture = state.getValue(BlockFarmland.MOISTURE);
|
int moisture = state.getValue(BlockFarmland.MOISTURE);
|
||||||
|
|
||||||
if (moisture < 7) {
|
if (moisture < 7) {
|
||||||
world.setBlockState(below, state.withProperty(BlockFarmland.MOISTURE, moisture + 1));
|
world.setBlockState(below, state.withProperty(BlockFarmland.MOISTURE, moisture + 1));
|
||||||
}
|
}
|
||||||
} else if (state.getBlock() instanceof BlockCrops) {
|
} else if (state.getBlock() instanceof BlockCrops) {
|
||||||
int age = state.getValue(BlockCrops.AGE);
|
int age = state.getValue(BlockCrops.AGE);
|
||||||
|
|
||||||
if (age < 7) {
|
if (age < 7) {
|
||||||
world.setBlockState(below, state.withProperty(BlockCrops.AGE, age + 1), 2);
|
world.setBlockState(below, state.withProperty(BlockCrops.AGE, age + 1), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.getBlock().fillWithRain(world, below);
|
state.getBlock().fillWithRain(world, below);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setRainTimer(getRainTimer() - 1) == 0) {
|
if (setRainTimer(getRainTimer() - 1) == 0) {
|
||||||
if (rand.nextInt(20000) == 0) {
|
if (rand.nextInt(20000) == 0) {
|
||||||
setDead();
|
setDead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rand.nextInt(8000) == 0 && canRainHere()) {
|
if (rand.nextInt(8000) == 0 && canRainHere()) {
|
||||||
setRaining();
|
setRaining();
|
||||||
if (rand.nextInt(7000) == 0) {
|
if (rand.nextInt(7000) == 0) {
|
||||||
setIsThundering(true);
|
setIsThundering(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rotationPitch = 0;
|
rotationPitch = 0;
|
||||||
rotationYawHead = 0;
|
rotationYawHead = 0;
|
||||||
|
@ -286,27 +286,27 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBurning() && !dead) {
|
if (isBurning() && !dead) {
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
world.spawnParticle(EnumParticleTypes.CLOUD,
|
world.spawnParticle(EnumParticleTypes.CLOUD,
|
||||||
posX + randomIn(rand, boundingbox.minX, boundingbox.maxX),
|
posX + randomIn(rand, boundingbox.minX, boundingbox.maxX),
|
||||||
posY + randomIn(rand, boundingbox.minY, boundingbox.maxY),
|
posY + randomIn(rand, boundingbox.minY, boundingbox.maxY),
|
||||||
posZ + randomIn(rand, boundingbox.minZ, boundingbox.maxZ), 0, 0.25, 0);
|
posZ + randomIn(rand, boundingbox.minZ, boundingbox.maxZ), 0, 0.25, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getStationary()) {
|
if (getStationary()) {
|
||||||
motionX = 0;
|
motionX = 0;
|
||||||
motionY = 0;
|
motionY = 0;
|
||||||
motionZ = 0;
|
motionZ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
motionX /= (1 + getCloudSize());
|
motionX /= (1 + getCloudSize());
|
||||||
motionZ /= (1 + getCloudSize());
|
motionZ /= (1 + getCloudSize());
|
||||||
|
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
|
|
||||||
hurtTime = 0;
|
hurtTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -316,62 +316,62 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveRelative(float strafe, float up, float forward, float friction) {
|
public void moveRelative(float strafe, float up, float forward, float friction) {
|
||||||
if (!getStationary()) {
|
if (!getStationary()) {
|
||||||
super.moveRelative(strafe, up, forward, friction);
|
super.moveRelative(strafe, up, forward, friction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCollideWithPlayer(EntityPlayer player) {
|
public void onCollideWithPlayer(EntityPlayer player) {
|
||||||
if (player.posY >= posY) {
|
if (player.posY >= posY) {
|
||||||
if (applyGravityCompensation(player)) {
|
if (applyGravityCompensation(player)) {
|
||||||
double difX = player.posX - player.lastTickPosX;
|
double difX = player.posX - player.lastTickPosX;
|
||||||
double difZ = player.posZ - player.lastTickPosZ;
|
double difZ = player.posZ - player.lastTickPosZ;
|
||||||
double difY = player.posY - player.lastTickPosY;
|
double difY = player.posY - player.lastTickPosY;
|
||||||
|
|
||||||
player.distanceWalkedModified = (float)(player.distanceWalkedModified + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
|
player.distanceWalkedModified = (float)(player.distanceWalkedModified + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
|
||||||
player.distanceWalkedOnStepModified = (float)(player.distanceWalkedOnStepModified + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
|
player.distanceWalkedOnStepModified = (float)(player.distanceWalkedOnStepModified + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
|
||||||
|
|
||||||
if (PlayerSpeciesList.instance().getPlayer(player).stepOnCloud()) {
|
if (PlayerSpeciesList.instance().getPlayer(player).stepOnCloud()) {
|
||||||
SoundType soundtype = SoundType.CLOTH;
|
SoundType soundtype = SoundType.CLOTH;
|
||||||
player.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
|
player.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onCollideWithPlayer(player);
|
super.onCollideWithPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateAITasks() {
|
protected void updateAITasks() {
|
||||||
if (!getStationary()) {
|
if (!getStationary()) {
|
||||||
super.updateAITasks();
|
super.updateAITasks();
|
||||||
|
|
||||||
if (!isBeingRidden()) {
|
if (!isBeingRidden()) {
|
||||||
double distance = targetAltitude - posY;
|
double distance = targetAltitude - posY;
|
||||||
|
|
||||||
if (Math.abs(distance) < 1 && rand.nextInt(7000) == 0) {
|
if (Math.abs(distance) < 1 && rand.nextInt(7000) == 0) {
|
||||||
targetAltitude = getRandomFlyingHeight();
|
targetAltitude = getRandomFlyingHeight();
|
||||||
distance = targetAltitude - posY;
|
distance = targetAltitude - posY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rand.nextInt(7000) == 0) {
|
if (rand.nextInt(7000) == 0) {
|
||||||
directionX = directionX == 0 ? rand.nextInt(3) - 1 : 0;
|
directionX = directionX == 0 ? rand.nextInt(3) - 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rand.nextInt(7000) == 0) {
|
if (rand.nextInt(7000) == 0) {
|
||||||
directionZ = directionZ == 0 ? rand.nextInt(3) - 1 : 0;
|
directionZ = directionZ == 0 ? rand.nextInt(3) - 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.abs(distance) < 1) {
|
if (Math.abs(distance) < 1) {
|
||||||
distance = 0;
|
distance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
motionX -= 0.02;
|
motionX -= 0.02;
|
||||||
motionX -= (Math.signum(directionX) * 0.699999988079071D - motionX) * 0.10000000149011612D;
|
motionX -= (Math.signum(directionX) * 0.699999988079071D - motionX) * 0.10000000149011612D;
|
||||||
motionY += (Math.signum(distance) * 0.699999988079071D - motionY) * 0.10000000149011612D;
|
motionY += (Math.signum(distance) * 0.699999988079071D - motionY) * 0.10000000149011612D;
|
||||||
motionZ -= (Math.signum(directionZ) * 0.699999988079071D - motionZ) * 0.10000000149011612D;
|
motionZ -= (Math.signum(directionZ) * 0.699999988079071D - motionZ) * 0.10000000149011612D;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float getRandomFlyingHeight() {
|
protected float getRandomFlyingHeight() {
|
||||||
|
@ -400,52 +400,52 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
|
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
|
||||||
if (!(isBeingRidden() || isRidingOrBeingRiddenBy(player)) && hand == EnumHand.MAIN_HAND) {
|
if (!(isBeingRidden() || isRidingOrBeingRiddenBy(player)) && hand == EnumHand.MAIN_HAND) {
|
||||||
if (Predicates.INTERACT_WITH_CLOUDS.test(player)) {
|
if (Predicates.INTERACT_WITH_CLOUDS.test(player)) {
|
||||||
|
|
||||||
if (player.getItemInUseCount() > 0) {
|
if (player.getItemInUseCount() > 0) {
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
if (stack.getItem() instanceof ItemBlock || stack.getItem() == Items.SPAWN_EGG && stack.getItemDamage() == EntityList.getID(EntityCloud.class)) {
|
if (stack.getItem() instanceof ItemBlock || stack.getItem() == Items.SPAWN_EGG && stack.getItemDamage() == EntityList.getID(EntityCloud.class)) {
|
||||||
placeBlock(player, stack, hand);
|
placeBlock(player, stack, hand);
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getStationary()) {
|
if (!getStationary()) {
|
||||||
player.startRiding(this);
|
player.startRiding(this);
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleStatusUpdate(byte type) {
|
public void handleStatusUpdate(byte type) {
|
||||||
if (type == 2) {
|
if (type == 2) {
|
||||||
if (!isBurning()) {
|
if (!isBurning()) {
|
||||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState());
|
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.handleStatusUpdate(type);
|
super.handleStatusUpdate(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||||
Entity attacker = source.getImmediateSource();
|
Entity attacker = source.getImmediateSource();
|
||||||
|
|
||||||
if (attacker instanceof EntityPlayer) {
|
if (attacker instanceof EntityPlayer) {
|
||||||
return onAttackByPlayer(source, amount, (EntityPlayer)attacker);
|
return onAttackByPlayer(source, amount, (EntityPlayer)attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
return source == DamageSource.IN_WALL || super.attackEntityFrom(source, amount);
|
return source == DamageSource.IN_WALL || super.attackEntityFrom(source, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeBlock(EntityPlayer player, ItemStack stack, EnumHand hand) {
|
private void placeBlock(EntityPlayer player, ItemStack stack, EnumHand hand) {
|
||||||
|
@ -455,32 +455,32 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
double distance = mc.playerController.getBlockReachDistance();
|
double distance = mc.playerController.getBlockReachDistance();
|
||||||
|
|
||||||
float ticks = mc.getRenderPartialTicks();
|
float ticks = mc.getRenderPartialTicks();
|
||||||
|
|
||||||
Vec3d eye = player.getPositionEyes(ticks);
|
Vec3d eye = player.getPositionEyes(ticks);
|
||||||
Vec3d look = player.getLook(ticks);
|
Vec3d look = player.getLook(ticks);
|
||||||
Vec3d ray = eye.add(look.x * distance, look.y * distance, look.z * distance);
|
Vec3d ray = eye.add(look.x * distance, look.y * distance, look.z * distance);
|
||||||
|
|
||||||
AxisAlignedBB bounds = getEntityBoundingBox();
|
AxisAlignedBB bounds = getEntityBoundingBox();
|
||||||
|
|
||||||
float s = 0.5F;
|
float s = 0.5F;
|
||||||
RayTraceResult trace = bounds
|
RayTraceResult trace = bounds
|
||||||
.contract(0, s, 0).contract(0, -s, 0)
|
.contract(0, s, 0).contract(0, -s, 0)
|
||||||
.calculateIntercept(eye, ray);
|
.calculateIntercept(eye, ray);
|
||||||
|
|
||||||
if (trace == null) {
|
if (trace == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumFacing direction = trace.sideHit;
|
EnumFacing direction = trace.sideHit;
|
||||||
|
|
||||||
BlockPos blockPos = new BlockPos(trace.hitVec);
|
BlockPos blockPos = new BlockPos(trace.hitVec);
|
||||||
|
|
||||||
mc.objectMouseOver = new RayTraceResult(trace.hitVec, direction, blockPos);
|
mc.objectMouseOver = new RayTraceResult(trace.hitVec, direction, blockPos);
|
||||||
|
|
||||||
int oldCount = stack.getCount();
|
int oldCount = stack.getCount();
|
||||||
EnumActionResult result = mc.playerController.processRightClickBlock(((EntityPlayerSP)player), (WorldClient)player.world, blockPos, direction, trace.hitVec, hand);
|
EnumActionResult result = mc.playerController.processRightClickBlock(((EntityPlayerSP)player), (WorldClient)player.world, blockPos, direction, trace.hitVec, hand);
|
||||||
|
|
||||||
if (result == EnumActionResult.SUCCESS) {
|
if (result == EnumActionResult.SUCCESS) {
|
||||||
|
@ -496,44 +496,44 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
|
|
||||||
boolean canFly = EnchantmentHelper.getEnchantments(stack).containsKey(Enchantments.FEATHER_FALLING)
|
boolean canFly = EnchantmentHelper.getEnchantments(stack).containsKey(Enchantments.FEATHER_FALLING)
|
||||||
|| Predicates.INTERACT_WITH_CLOUDS.test(player);
|
|| Predicates.INTERACT_WITH_CLOUDS.test(player);
|
||||||
boolean stat = getStationary();
|
boolean stat = getStationary();
|
||||||
|
|
||||||
if (stat || canFly) {
|
if (stat || canFly) {
|
||||||
if (!isBurning()) {
|
if (!isBurning()) {
|
||||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState());
|
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (stack != null && stack.getItem() instanceof ItemSword) {
|
if (stack != null && stack.getItem() instanceof ItemSword) {
|
||||||
return super.attackEntityFrom(source, amount);
|
return super.attackEntityFrom(source, amount);
|
||||||
} else if (stack != null && stack.getItem() instanceof ItemSpade) {
|
} else if (stack != null && stack.getItem() instanceof ItemSpade) {
|
||||||
return super.attackEntityFrom(source, amount * 1.5f);
|
return super.attackEntityFrom(source, amount * 1.5f);
|
||||||
} else if (canFly) {
|
} else if (canFly) {
|
||||||
if (player.posY < posY) {
|
if (player.posY < posY) {
|
||||||
targetAltitude = posY + 5;
|
targetAltitude = posY + 5;
|
||||||
} else if (player.posY > posY) {
|
} else if (player.posY > posY) {
|
||||||
targetAltitude = posY - 5;
|
targetAltitude = posY - 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeath(DamageSource s) {
|
public void onDeath(DamageSource s) {
|
||||||
if (s == DamageSource.GENERIC || (s.getTrueSource() != null && s.getTrueSource() instanceof EntityPlayer)) {
|
if (s == DamageSource.GENERIC || (s.getTrueSource() != null && s.getTrueSource() instanceof EntityPlayer)) {
|
||||||
if (!isBurning()) {
|
if (!isBurning()) {
|
||||||
Particles.instance().getEntityEmitter().emitDestructionParticles(this, UBlocks.cloud.getDefaultState());
|
Particles.instance().getEntityEmitter().emitDestructionParticles(this, UBlocks.cloud.getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
setDead();
|
setDead();
|
||||||
}
|
}
|
||||||
super.onDeath(s);
|
super.onDeath(s);
|
||||||
clearItemFloatingState();
|
clearItemFloatingState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -559,16 +559,16 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dropFewItems(boolean hitByPlayer, int looting) {
|
protected void dropFewItems(boolean hitByPlayer, int looting) {
|
||||||
if (hitByPlayer) {
|
if (hitByPlayer) {
|
||||||
Item item = getDropItem();
|
Item item = getDropItem();
|
||||||
int amount = 2 + world.rand.nextInt(3);
|
int amount = 2 + world.rand.nextInt(3);
|
||||||
|
|
||||||
dropItem(item, amount * (1 + looting));
|
dropItem(item, amount * (1 + looting));
|
||||||
|
|
||||||
if (world.rand.nextBoolean()) {
|
if (world.rand.nextBoolean()) {
|
||||||
dropItem(UItems.dew_drop, 2 + looting);
|
dropItem(UItems.dew_drop, 2 + looting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -594,32 +594,32 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
protected boolean applyGravityCompensation(Entity entity) {
|
protected boolean applyGravityCompensation(Entity entity) {
|
||||||
int floatStrength = getFloatStrength(entity);
|
int floatStrength = getFloatStrength(entity);
|
||||||
|
|
||||||
if (!isRidingOrBeingRiddenBy(entity) && floatStrength > 0) {
|
if (!isRidingOrBeingRiddenBy(entity) && floatStrength > 0) {
|
||||||
|
|
||||||
double boundModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10;
|
double boundModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10;
|
||||||
|
|
||||||
entity.onGround = true;
|
entity.onGround = true;
|
||||||
entity.motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - entity.motionY + boundModifier * 0.7) * 0.10000000149011612D;
|
entity.motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - entity.motionY + boundModifier * 0.7) * 0.10000000149011612D;
|
||||||
if (!getStationary()) {
|
if (!getStationary()) {
|
||||||
entity.motionX -= 0.013;
|
entity.motionX -= 0.013;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getStationary() && entity.motionY > 0.4 && world.rand.nextInt(900) == 0) {
|
if (!getStationary() && entity.motionY > 0.4 && world.rand.nextInt(900) == 0) {
|
||||||
spawnThunderbolt(getPosition());
|
spawnThunderbolt(getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
// @FUF(reason = "There is no TickEvents.EntityTickEvent. Waiting on mixins...")
|
// @FUF(reason = "There is no TickEvents.EntityTickEvent. Waiting on mixins...")
|
||||||
if (getStationary() && entity instanceof EntityItem) {
|
if (getStationary() && entity instanceof EntityItem) {
|
||||||
entity.motionX /= 8;
|
entity.motionX /= 8;
|
||||||
entity.motionZ /= 8;
|
entity.motionZ /= 8;
|
||||||
entity.motionY /= 16;
|
entity.motionY /= 16;
|
||||||
entity.setNoGravity(true);
|
entity.setNoGravity(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -633,115 +633,115 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
this.resetPositionToBB();
|
this.resetPositionToBB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFloatStrength(Entity entity) {
|
public int getFloatStrength(Entity entity) {
|
||||||
if (Predicates.ENTITY_INTERACT_WITH_CLOUDS.test(entity)) {
|
if (Predicates.ENTITY_INTERACT_WITH_CLOUDS.test(entity)) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
return getFeatherEnchantStrength((EntityPlayer)entity);
|
return getFeatherEnchantStrength((EntityPlayer)entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getFeatherEnchantStrength(EntityPlayer player) {
|
public static int getFeatherEnchantStrength(EntityPlayer player) {
|
||||||
for (ItemStack stack : player.getArmorInventoryList()) {
|
for (ItemStack stack : player.getArmorInventoryList()) {
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
|
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
|
||||||
if (enchantments.containsKey(Enchantments.FEATHER_FALLING)) {
|
if (enchantments.containsKey(Enchantments.FEATHER_FALLING)) {
|
||||||
return (Integer)enchantments.get(Enchantments.FEATHER_FALLING);
|
return (Integer)enchantments.get(Enchantments.FEATHER_FALLING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canRainHere() {
|
private boolean canRainHere() {
|
||||||
return world.getBiome(new BlockPos(posX, posY, posZ)).canRain();
|
return world.getBiome(new BlockPos(posX, posY, posZ)).canRain();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSnowHere(BlockPos pos) {
|
private boolean canSnowHere(BlockPos pos) {
|
||||||
return world.getBiome(pos).getTemperature(pos) <= 0.15f;
|
return world.getBiome(pos).getTemperature(pos) <= 0.15f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnThunderbolt() {
|
public void spawnThunderbolt() {
|
||||||
spawnThunderbolt(getGroundPosition(posX, posZ));
|
spawnThunderbolt(getGroundPosition(posX, posZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnThunderbolt(BlockPos pos) {
|
public void spawnThunderbolt(BlockPos pos) {
|
||||||
world.addWeatherEffect(new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), false));
|
world.addWeatherEffect(new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos getGroundPosition(double x, double z) {
|
private BlockPos getGroundPosition(double x, double z) {
|
||||||
BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, posY, z));
|
BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, posY, z));
|
||||||
|
|
||||||
if (pos.getY() >= posY) {
|
if (pos.getY() >= posY) {
|
||||||
while (world.isValid(pos)) {
|
while (world.isValid(pos)) {
|
||||||
pos = pos.down();
|
pos = pos.down();
|
||||||
if (world.getBlockState(pos).isSideSolid(world, pos, EnumFacing.UP)) {
|
if (world.getBlockState(pos).isSideSolid(world, pos, EnumFacing.UP)) {
|
||||||
return pos.up();
|
return pos.up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRainTimer() {
|
public int getRainTimer() {
|
||||||
return dataManager.get(RAINTIMER);
|
return dataManager.get(RAINTIMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int setRainTimer(int val) {
|
public int setRainTimer(int val) {
|
||||||
val = Math.max(0, val);
|
val = Math.max(0, val);
|
||||||
dataManager.set(RAINTIMER, val);
|
dataManager.set(RAINTIMER, val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRaining() {
|
private void setRaining() {
|
||||||
setRainTimer(700 + rand.nextInt(20));
|
setRainTimer(700 + rand.nextInt(20));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsRaining(boolean val) {
|
public void setIsRaining(boolean val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
setRaining();
|
setRaining();
|
||||||
} else {
|
} else {
|
||||||
setRainTimer(0);
|
setRainTimer(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsRaining() {
|
public boolean getIsRaining() {
|
||||||
return getRainTimer() > 0;
|
return getRainTimer() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsThundering() {
|
public boolean getIsThundering() {
|
||||||
return dataManager.get(THUNDERING);
|
return dataManager.get(THUNDERING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsThundering(boolean val) {
|
public void setIsThundering(boolean val) {
|
||||||
dataManager.set(THUNDERING, val);
|
dataManager.set(THUNDERING, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getStationary() {
|
public boolean getStationary() {
|
||||||
return dataManager.get(STATIONARY);
|
return dataManager.get(STATIONARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStationary(boolean val) {
|
public void setStationary(boolean val) {
|
||||||
dataManager.set(STATIONARY, val);
|
dataManager.set(STATIONARY, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getOpaque() {
|
public boolean getOpaque() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCloudSize() {
|
public int getCloudSize() {
|
||||||
int size = dataManager.get(SCALE);
|
int size = dataManager.get(SCALE);
|
||||||
updateSize(size);
|
updateSize(size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSize(int scale) {
|
private void updateSize(int scale) {
|
||||||
setSize((float)baseWidth * scale, (float)baseHeight * scale);
|
setSize((float)baseWidth * scale, (float)baseHeight * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -754,7 +754,7 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
||||||
|
|
||||||
public void setCloudSize(int val) {
|
public void setCloudSize(int val) {
|
||||||
val = Math.max(1, val);
|
val = Math.max(1, val);
|
||||||
updateSize(val);
|
updateSize(val);
|
||||||
dataManager.set(SCALE, val);
|
dataManager.set(SCALE, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@ public class RenderCloud extends RenderLiving<EntityCloud> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float prepareScale(EntityCloud entity, float par2) {
|
public float prepareScale(EntityCloud entity, float par2) {
|
||||||
float scale = entity.getCloudSize();
|
float scale = entity.getCloudSize();
|
||||||
|
|
||||||
GL11.glScalef(scale, scale, scale);
|
GL11.glScalef(scale, scale, scale);
|
||||||
return 0.0625F;
|
return 0.0625F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,25 +36,25 @@ public class RenderCloud extends RenderLiving<EntityCloud> {
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
|
|
||||||
GlStateManager.color(1, 1, 1, entity.getOpaque() ? 1 : 0.8F);
|
GlStateManager.color(1, 1, 1, entity.getOpaque() ? 1 : 0.8F);
|
||||||
|
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
super.renderModel(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor);
|
super.renderModel(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor);
|
||||||
|
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.enableLighting();
|
GlStateManager.enableLighting();
|
||||||
GlStateManager.color(1, 1, 1, 1);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getEntityTexture(EntityCloud entity) {
|
protected ResourceLocation getEntityTexture(EntityCloud entity) {
|
||||||
if (entity.getIsRaining() && entity.getIsThundering()) {
|
if (entity.getIsRaining() && entity.getIsThundering()) {
|
||||||
return rainCloud;
|
return rainCloud;
|
||||||
}
|
}
|
||||||
return cloud;
|
return cloud;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue