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