This commit is contained in:
Vincent Lee committed 2016-03-18 14:47:38 -05:00
1 parent 017829927f
commit cfbf2cc538
14 files changed
+343 -282

No files matched your search

@@ -11,8 +11,8 @@
package vazkii.botania.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
import net.minecraft.event.HoverEvent;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.Style;
@@ -93,8 +93,8 @@ public class Botania {
message2.setChatStyle(new Style().setColor(TextFormatting.YELLOW));
ITextComponent url = new TextComponentString("https://github.com/williewillus/Botania/issues");
url.getStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/williewillus/Botania/issues"));
url.getStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("CLICK")));
url.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/williewillus/Botania/issues"));
url.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("CLICK")));
player.addChatComponentMessage(message);
@@ -16,11 +16,18 @@ 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.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import scala.tools.nsc.backend.icode.TypeKinds;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
@@ -35,6 +42,13 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
private static final String TAG_DELAY = "delay";
private static final String TAG_ROTATION = "rotation";
private static final DataParameter<Boolean> CHARGING = EntityDataManager.createKey(EntityBabylonWeapon.class, DataSerializers.BOOLEAN);
private static final DataParameter<Integer> VARIETY = EntityDataManager.createKey(EntityBabylonWeapon.class, DataSerializers.VARINT);
private static final DataParameter<Integer> CHARGE_TICKS = EntityDataManager.createKey(EntityBabylonWeapon.class, DataSerializers.VARINT);
private static final DataParameter<Integer> LIVE_TICKS = EntityDataManager.createKey(EntityBabylonWeapon.class, DataSerializers.VARINT);
private static final DataParameter<Integer> DELAY = EntityDataManager.createKey(EntityBabylonWeapon.class, DataSerializers.VARINT);
private static final DataParameter<Float> ROTATION = EntityDataManager.createKey(EntityBabylonWeapon.class, DataSerializers.FLOAT);
public EntityBabylonWeapon(World world) {
super(world);
}
@@ -45,21 +59,15 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
@Override
protected void entityInit() {
super.entityInit();
setSize(0F, 0F);
dataWatcher.addObject(20, (byte) 0);
dataWatcher.addObject(21, 0);
dataWatcher.addObject(22, 0);
dataWatcher.addObject(23, 0);
dataWatcher.addObject(24, 0);
dataWatcher.addObject(25, 0F);
dataWatcher.setObjectWatched(20);
dataWatcher.setObjectWatched(21);
dataWatcher.setObjectWatched(22);
dataWatcher.setObjectWatched(23);
dataWatcher.setObjectWatched(24);
dataWatcher.setObjectWatched(25);
dataWatcher.register(CHARGING, false);
dataWatcher.register(VARIETY, 0);
dataWatcher.register(CHARGE_TICKS, 0);
dataWatcher.register(LIVE_TICKS, 0);
dataWatcher.register(DELAY, 0);
dataWatcher.register(ROTATION, 0F);
}
@Override
@@ -72,8 +80,8 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
EntityPlayer player = (EntityPlayer) thrower;
boolean charging = isCharging();
if(!worldObj.isRemote) {
ItemStack stack = player == null ? null : player.getCurrentEquippedItem();
boolean newCharging = stack != null && stack.getItem() == ModItems.kingKey && ItemKingKey.isCharging(stack);
ItemStack stack = player == null ? null : PlayerHelper.getFirstHeldItem(player, ModItems.kingKey);
boolean newCharging = stack != null && ItemKingKey.isCharging(stack);
if(charging != newCharging) {
setCharging(newCharging);
charging = newCharging;
@@ -97,7 +105,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
setChargeTicks(chargeTime + 1);
if(worldObj.rand.nextInt(20) == 0)
worldObj.playSoundAtEntity(this, "botania:babylonSpawn", 0.1F, 1F + worldObj.rand.nextFloat() * 3F);
worldObj.playSound(null, posX, posY, posZ, BotaniaSoundEvents.babylonSpawn, SoundCategory.PLAYERS, 0.1F, 1F + worldObj.rand.nextFloat() * 3F);
} else {
if(liveTime < delay) {
motionX = 0;
@@ -116,7 +124,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
x = motionVec.x;
y = motionVec.y;
z = motionVec.z;
worldObj.playSoundAtEntity(this, "botania:babylonAttack", 2F, 0.1F + worldObj.rand.nextFloat() * 3F);
worldObj.playSound(null, posX, posY, posZ, BotaniaSoundEvents.babylonAttack, SoundCategory.PLAYERS, 2F, 0.1F + worldObj.rand.nextFloat() * 3F);
}
setLiveTicks(liveTime + 1);
@@ -183,51 +191,51 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
}
public boolean isCharging() {
return dataWatcher.getWatchableObjectByte(20) == 1;
return dataWatcher.get(CHARGING);
}
public void setCharging(boolean charging) {
dataWatcher.updateObject(20, (byte) (charging ? 1 : 0));
dataWatcher.set(CHARGING, charging);
}
public int getVariety() {
return dataWatcher.getWatchableObjectInt(21);
return dataWatcher.get(VARIETY);
}
public void setVariety(int var) {
dataWatcher.updateObject(21, var);
dataWatcher.set(VARIETY, var);
}
public int getChargeTicks() {
return dataWatcher.getWatchableObjectInt(22);
return dataWatcher.get(CHARGE_TICKS);
}
public void setChargeTicks(int ticks) {
dataWatcher.updateObject(22, ticks);
dataWatcher.set(CHARGE_TICKS, ticks);
}
public int getLiveTicks() {
return dataWatcher.getWatchableObjectInt(23);
return dataWatcher.get(LIVE_TICKS);
}
public void setLiveTicks(int ticks) {
dataWatcher.updateObject(23, ticks);
dataWatcher.set(LIVE_TICKS, ticks);
}
public int getDelay() {
return dataWatcher.getWatchableObjectInt(24);
return dataWatcher.get(DELAY);
}
public void setDelay(int delay) {
dataWatcher.updateObject(24, delay);
dataWatcher.set(DELAY, delay);
}
public float getRotation() {
return dataWatcher.getWatchableObjectFloat(25);
return dataWatcher.get(ROTATION);
}
public void setRotation(float rot) {
dataWatcher.updateObject(25, rot);
dataWatcher.set(ROTATION, rot);
}
}
@@ -38,10 +38,16 @@ import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -65,6 +71,7 @@ import vazkii.botania.api.internal.ShaderCallback;
import vazkii.botania.api.lexicon.multiblock.Multiblock;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.state.enums.PylonVariant;
import vazkii.botania.client.core.handler.BossBarHandler;
@@ -81,16 +88,16 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWithShader {
public static final int SPAWN_TICKS = 160;
private static final int SPAWN_TICKS = 160;
private static final float RANGE = 12F;
private static final float MAX_HP = 800F;
public static final int MOB_SPAWN_START_TICKS = 20;
public static final int MOB_SPAWN_END_TICKS = 80;
public static final int MOB_SPAWN_BASE_TICKS = 800;
public static final int MOB_SPAWN_TICKS = MOB_SPAWN_BASE_TICKS + MOB_SPAWN_START_TICKS + MOB_SPAWN_END_TICKS;
public static final int MOB_SPAWN_WAVES = 10;
public static final int MOB_SPAWN_WAVE_TIME = MOB_SPAWN_BASE_TICKS / MOB_SPAWN_WAVES;
private static final int MOB_SPAWN_START_TICKS = 20;
private static final int MOB_SPAWN_END_TICKS = 80;
private static final int MOB_SPAWN_BASE_TICKS = 800;
private static final int MOB_SPAWN_TICKS = MOB_SPAWN_BASE_TICKS + MOB_SPAWN_START_TICKS + MOB_SPAWN_END_TICKS;
private static final int MOB_SPAWN_WAVES = 10;
private static final int MOB_SPAWN_WAVE_TIME = MOB_SPAWN_BASE_TICKS / MOB_SPAWN_WAVES;
private static final String TAG_INVUL_TIME = "invulTime";
private static final String TAG_AGGRO = "aggro";
@@ -101,6 +108,14 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
private static final String TAG_HARD_MODE = "hardMode";
private static final String TAG_PLAYER_COUNT = "playerCount";
private static final DataParameter<Integer> INVUL_TIME = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
private static final DataParameter<Integer> DATA_MOB_SPAWN_TICKS = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
private static final DataParameter<Integer> PLAYER_COUNT = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
private static final DataParameter<Integer> TP_DELAY = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
private static final DataParameter<Boolean> AGGRO = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.BOOLEAN);
private static final DataParameter<Boolean> HARD_MODE = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.BOOLEAN);
private static final DataParameter<BlockPos> SOURCE = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.BLOCK_POS);
private static final BlockPos[] PYLON_LOCATIONS = {
new BlockPos(4, 1, 4),
new BlockPos(4, 1, -4),
@@ -203,9 +218,9 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
playerCount++;
e.setPlayerCount(playerCount);
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP * playerCount);
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount);
par3World.playSoundAtEntity(e, "mob.enderdragon.growl", 10F, 0.1F);
e.playSound(SoundEvents.entity_enderdragon_growl, 10F, 0.1F);
par3World.spawnEntityInWorld(e);
return true;
}
@@ -227,7 +242,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
yCheck: {
for(int k = heightCheck + heightMin + 1; k >= -heightCheck; k--) {
BlockPos pos = startPos.add(i, k, j);
boolean isAir = world.getBlockState(pos).getBlock().getCollisionBoundingBox(world, pos, world.getBlockState(pos)) == null;
boolean isAir = world.getBlockState(pos).getCollisionBoundingBox(world, pos) == null;
if(isAir)
air++;
else {
@@ -246,84 +261,72 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
return true;
}
// @Override todo 1.8 new AI
// protected boolean isAIEnabled() {
// return true;
// }
@Override
protected void entityInit() {
super.entityInit();
dataWatcher.addObject(20, 0); // Invul Time
dataWatcher.addObject(21, (byte) 0); // Aggro
dataWatcher.addObject(22, 0); // TP Delay
dataWatcher.addObject(23, 0); // Source X
dataWatcher.addObject(24, 0); // Source Y
dataWatcher.addObject(25, 0); // Source Z
dataWatcher.addObject(26, 0); // Ticks spawning mobs
dataWatcher.addObject(27, (byte) 0); // Hard Mode
dataWatcher.addObject(28, 0); // Player count
dataWatcher.register(INVUL_TIME, 0);
dataWatcher.register(AGGRO, false);
dataWatcher.register(TP_DELAY, 0);
dataWatcher.register(SOURCE, BlockPos.ORIGIN);
dataWatcher.register(DATA_MOB_SPAWN_TICKS, 0);
dataWatcher.register(HARD_MODE, false);
dataWatcher.register(PLAYER_COUNT, 0);
}
public int getInvulTime() {
return dataWatcher.getWatchableObjectInt(20);
return dataWatcher.get(INVUL_TIME);
}
public boolean isAggored() {
return dataWatcher.getWatchableObjectByte(21) == 1;
return dataWatcher.get(AGGRO);
}
public int getTPDelay() {
return dataWatcher.getWatchableObjectInt(22);
return dataWatcher.get(TP_DELAY);
}
public BlockPos getSource() {
int x = dataWatcher.getWatchableObjectInt(23);
int y = dataWatcher.getWatchableObjectInt(24);
int z = dataWatcher.getWatchableObjectInt(25);
return new BlockPos(x, y, z);
return dataWatcher.get(SOURCE);
}
public int getMobSpawnTicks() {
return dataWatcher.getWatchableObjectInt(26);
return dataWatcher.get(DATA_MOB_SPAWN_TICKS);
}
public boolean isHardMode() {
return dataWatcher.getWatchableObjectByte(27) == 1;
return dataWatcher.get(HARD_MODE);
}
public int getPlayerCount() {
return dataWatcher.getWatchableObjectInt(28);
return dataWatcher.get(PLAYER_COUNT);
}
public void setInvulTime(int time) {
dataWatcher.updateObject(20, time);
dataWatcher.set(INVUL_TIME, time);
}
public void setAggroed(boolean aggored) {
dataWatcher.updateObject(21, (byte) (aggored ? 1 : 0));
dataWatcher.set(AGGRO, aggored);
}
public void setTPDelay(int delay) {
dataWatcher.updateObject(22, delay);
dataWatcher.set(TP_DELAY, delay);
}
public void setSource(BlockPos pos) {
dataWatcher.updateObject(23, pos.getX());
dataWatcher.updateObject(24, pos.getY());
dataWatcher.updateObject(25, pos.getZ());
dataWatcher.set(SOURCE, pos);
}
public void setMobSpawnTicks(int ticks) {
dataWatcher.updateObject(26, ticks);
dataWatcher.set(DATA_MOB_SPAWN_TICKS, ticks);
}
public void setHardMode(boolean hardMode) {
dataWatcher.updateObject(27, (byte) (hardMode ? 1 : 0));
dataWatcher.set(HARD_MODE, hardMode);
}
public void setPlayerCount(int count) {
dataWatcher.updateObject(28, count);
dataWatcher.set(PLAYER_COUNT, count);
}
@Override
@@ -373,7 +376,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
boolean crit = false;
if(e instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) e;
crit = p.fallDistance > 0.0F && !p.onGround && !p.isOnLadder() && !p.isInWater() && !p.isPotionActive(Potion.blindness) && p.ridingEntity == null;
crit = p.fallDistance > 0.0F && !p.onGround && !p.isOnLadder() && !p.isInWater() && !p.isPotionActive(MobEffects.blindness) && !p.isRiding();
}
int cap = crit ? 60 : 40;
@@ -418,23 +421,23 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
@Override
public void onDeath(DamageSource p_70645_1_) {
super.onDeath(p_70645_1_);
EntityLivingBase entitylivingbase = func_94060_bK();
EntityLivingBase entitylivingbase = getAttackingEntity();
if(entitylivingbase instanceof EntityPlayer) {
((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianKill, 1);
if(!anyWithArmor)
((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianNoArmor, 1);
}
worldObj.playSoundAtEntity(this, "random.explode", 20F, (1F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
this.playSound(SoundEvents.entity_generic_explode, 20F, (1F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, posX, posY, posZ, 1D, 0D, 0D);
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4);
getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP);
getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0);
getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4);
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP);
getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(1.0);
}
@Override
@@ -504,19 +507,15 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
public List<EntityPlayer> getPlayersAround() {
BlockPos source = getSource();
float range = 15F;
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
return players;
return worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
}
@Override
public void onLivingUpdate() {
super.onLivingUpdate();
if(ridingEntity != null) {
if(ridingEntity.riddenByEntity != null)
ridingEntity.riddenByEntity = null;
ridingEntity = null;
}
if(!getPassengers().isEmpty())
this.dismountRidingEntity();
boolean peaceful = worldObj.getDifficulty() == EnumDifficulty.PEACEFUL;
if(!worldObj.isRemote && peaceful)
@@ -584,7 +583,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
List<PotionEffect> remove = new ArrayList<>();
Collection<PotionEffect> active = player.getActivePotionEffects();
for(PotionEffect effect : active)
if(effect.getDuration() < 200 && effect.getIsAmbient() && !GameData.getPotionRegistry().getObjectById(effect.getPotionID()).isBadEffect())
if(effect.getDuration() < 200 && effect.getIsAmbient() && !effect.getPotion().isBadEffect())
remove.add(effect);
active.removeAll(remove);
@@ -675,10 +674,10 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
}
case 1 : {
entity = new EntitySkeleton(worldObj);
entity.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.bow));
if(worldObj.rand.nextInt(8) == 0) {
((EntitySkeleton) entity).setSkeletonType(1);
entity.setCurrentItemOrArmor(0, new ItemStack(hard ? ModItems.elementiumSword : Items.stone_sword));
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(hard ? ModItems.elementiumSword : Items.stone_sword));
}
break;
}
@@ -767,7 +766,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
EntityMagicMissile missile = new EntityMagicMissile(this, true);
missile.setPosition(posX + (Math.random() - 0.5 * 0.1), posY + 2.4 + (Math.random() - 0.5 * 0.1), posZ + (Math.random() - 0.5 * 0.1));
if(missile.getTarget()) {
worldObj.playSoundAtEntity(this, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F);
this.playSound(BotaniaSoundEvents.missile, 0.6F, 0.8F + (float) Math.random() * 0.2F);
worldObj.spawnEntityInWorld(missile);
}
}
@@ -802,9 +801,10 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
boolean flag1 = false;
while(!flag1 && pos.getY() > 0) {
Block block = worldObj.getBlockState(pos.down()).getBlock();
IBlockState state = worldObj.getBlockState(pos.down());
Block block = state.getBlock();
if(block.getMaterial().blocksMovement())
if(block.getMaterial(state).blocksMovement())
flag1 = true;
else {
--posY;
@@ -815,7 +815,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
if(flag1) {
setPosition(posX, posY, posZ);
if(worldObj.getCollidingBoundingBoxes(this, getEntityBoundingBox()).isEmpty() && !worldObj.isAnyLiquid(getEntityBoundingBox()))
if(worldObj.getCubes(this, getEntityBoundingBox()).isEmpty() && !worldObj.isAnyLiquid(getEntityBoundingBox()))
flag = true;
// Prevent out of bounds teleporting
@@ -842,8 +842,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
worldObj.spawnParticle(EnumParticleTypes.PORTAL, d7, d8, d9, f, f1, f2);
}
worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F);
playSound("mob.endermen.portal", 1.0F, 1.0F);
playSound(SoundEvents.entity_endermen_teleport, 1.0F, 1.0F);
return true;
}
}
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockStateMatcher;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
@@ -54,8 +55,9 @@ public class EntityEnderAirBottle extends EntityThrowable {
int rangeY = 4;
for (BlockPos bPos : BlockPos.getAllInBox(pos.add(-range, -rangeY, -range), pos.add(range, rangeY, range))) {
Block block = worldObj.getBlockState(pos).getBlock();
if(block != null && block.isReplaceableOreGen(worldObj, pos, BlockStateMatcher.forBlock(Blocks.stone)))
IBlockState state = worldObj.getBlockState(pos);
Block block = state.getBlock();
if(block != null && block.isReplaceableOreGen(state, worldObj, pos, BlockStateMatcher.forBlock(Blocks.stone)))
possibleCoords.add(pos);
}
@@ -15,7 +15,9 @@ import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.SoundEvents;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
@@ -62,7 +64,7 @@ public class EntityFlameRing extends Entity {
}
if(worldObj.rand.nextInt(20) == 0)
worldObj.playSoundAtEntity(this, "fire.fire", 1F, 1F);
worldObj.playSound(null, posX, posY, posZ, SoundEvents.block_fire_ambient, SoundCategory.BLOCKS, 1F, 1F);
if(worldObj.isRemote)
return;
@@ -14,12 +14,15 @@ import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.Botania;
public class EntityMagicLandmine extends Entity {
@@ -49,7 +52,7 @@ public class EntityMagicLandmine extends Entity {
Botania.proxy.wispFX(worldObj, posX - range + Math.random() * range * 2, posY, posZ - range + Math.random() * range * 2, r, g, b, 0.4F, -0.015F, 1);
if(ticksExisted >= 55) {
worldObj.playSoundEffect(posX, posY, posZ, "botania:gaiaTrap", 0.3F, 1F);
worldObj.playSound(null, posX, posY, posZ, BotaniaSoundEvents.gaiaTrap, SoundCategory.NEUTRAL, 0.3F, 1F);
float m = 0.35F;
g = 0.4F;
@@ -60,8 +63,8 @@ public class EntityMagicLandmine extends Entity {
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range));
for(EntityPlayer player : players) {
player.attackEntityFrom(summoner == null ? DamageSource.generic : DamageSource.causeMobDamage(summoner), 10);
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 25, 0));
PotionEffect wither = new PotionEffect(Potion.wither.id, 70, 3);
player.addPotionEffect(new PotionEffect(MobEffects.blindness, 25, 0));
PotionEffect wither = new PotionEffect(MobEffects.wither, 70, 3);
wither.getCurativeItems().clear();
player.addPotionEffect(wither);
}
@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Random;
import java.util.UUID;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockLeaves;
@@ -27,8 +28,10 @@ import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
@@ -74,15 +77,19 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
private static final String TAG_SHOOTER_UUID_MOST = "shooterUUIDMost";
private static final String TAG_SHOOTER_UUID_LEAST = "shooterUUIDLeast";
private static final DataParameter<Integer> COLOR = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.VARINT);
private static final DataParameter<Integer> MANA = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.VARINT);
private static final DataParameter<Integer> START_MANA = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.VARINT);
private static final DataParameter<Integer> MIN_MANA_LOSS = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.VARINT);
private static final DataParameter<Float> MANA_LOSS_PER_TICK = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.FLOAT);
private static final DataParameter<Float> GRAVITY = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.FLOAT);
private static final DataParameter<BlockPos> SOURCE_COORDS = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.BLOCK_POS);
private static final DataParameter<Optional<ItemStack>> SOURCE_LENS = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.OPTIONAL_ITEM_STACK);
boolean fake = false;
final int dataWatcherEntries = 10;
final int dataWatcherStart = 32 - dataWatcherEntries;
List<String> alreadyCollidedAt = new ArrayList<>();
boolean fullManaLastTick = true;
UUID shooterIdentity = null;
int _ticksExisted = 0;
boolean scanBeam = false;
@@ -91,16 +98,19 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
public EntityManaBurst(World world) {
super(world);
setSize(0F, 0F);
for(int i = 0; i < dataWatcherEntries; i++) {
int j = dataWatcherStart + i;
if(i == 4 || i == 5)
dataWatcher.addObject(j, 0F);
else if(i == 9)
dataWatcher.addObject(j, new ItemStack(Blocks.stone, 0, 0));
else dataWatcher.addObject(j, 0);
}
dataWatcher.setObjectWatched(j);
}
@Override
protected void entityInit() {
super.entityInit();
dataWatcher.register(COLOR, 0);
dataWatcher.register(MANA, 0);
dataWatcher.register(START_MANA, 0);
dataWatcher.register(MIN_MANA_LOSS, 0);
dataWatcher.register(MANA_LOSS_PER_TICK, 0F);
dataWatcher.register(GRAVITY, 0F);
dataWatcher.register(SOURCE_COORDS, BlockPos.ORIGIN);
dataWatcher.register(SOURCE_LENS, Optional.absent());
}
public EntityManaBurst(IManaSpreader spreader, boolean fake) {
@@ -118,7 +128,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
float f = 0.4F;
double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D;
double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D;
double my = MathHelper.sin((rotationPitch + getInaccuracy()) / 180.0F * (float) Math.PI) * f / 2D;
double my = MathHelper.sin((rotationPitch) / 180.0F * (float) Math.PI) * f / 2D;
setMotion(mx, my, mz);
}
@@ -136,7 +146,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
float f = 0.4F;
double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D;
double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D;
double my = MathHelper.sin((rotationPitch + getInaccuracy()) / 180.0F * (float) Math.PI) * f / 2D;
double my = MathHelper.sin((rotationPitch) / 180.0F * (float) Math.PI) * f / 2D;
setMotion(mx, my, mz);
}
@@ -233,8 +243,8 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
IBlockState state = worldObj.getBlockState(pos);
Block block = state.getBlock();
if (block != null && (!par4 || block == null || block.getCollisionBoundingBox(worldObj, pos, state) != null) && block != Blocks.air && block.canCollideCheck(state, par3)) {
RayTraceResult RayTraceResult = block.collisionRayTrace(worldObj, pos, par1Vec3, par2Vec3);
if (block != null && (!par4 || block == null || state.getCollisionBoundingBox(worldObj, pos) != null) && block != Blocks.air && block.canCollideCheck(state, par3)) {
RayTraceResult RayTraceResult = state.collisionRayTrace(worldObj, pos, par1Vec3, par2Vec3);
if (RayTraceResult != null)
return RayTraceResult;
@@ -341,8 +351,8 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
IBlockState state1 = worldObj.getBlockState(pos1);
Block block1 = state1.getBlock();
if ((!par4 || block1 == null || block1.getCollisionBoundingBox(worldObj, pos1, state) != null) && block1 != Blocks.air && block1.canCollideCheck(state, par3)) {
RayTraceResult RayTraceResult1 = block1.collisionRayTrace(worldObj, pos1, par1Vec3, par2Vec3);
if ((!par4 || block1 == null || block1.getCollisionBoundingBox(state1, worldObj, pos1) != null) && block1 != Blocks.air && block1.canCollideCheck(state, par3)) {
RayTraceResult RayTraceResult1 = block1.collisionRayTrace(state1, worldObj, pos1, par1Vec3, par2Vec3);
if (RayTraceResult1 != null)
return RayTraceResult1;
@@ -685,90 +695,85 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
@Override
public int getColor() {
return dataWatcher.getWatchableObjectInt(dataWatcherStart);
return dataWatcher.get(COLOR);
}
@Override
public void setColor(int color) {
dataWatcher.updateObject(dataWatcherStart, color);
dataWatcher.set(COLOR, color);
}
@Override
public int getMana() {
return dataWatcher.getWatchableObjectInt(dataWatcherStart + 1);
return dataWatcher.get(MANA);
}
@Override
public void setMana(int mana) {
dataWatcher.updateObject(dataWatcherStart + 1, mana);
dataWatcher.set(MANA, mana);
}
@Override
public int getStartingMana() {
return dataWatcher.getWatchableObjectInt(dataWatcherStart + 2);
return dataWatcher.get(START_MANA);
}
@Override
public void setStartingMana(int mana) {
dataWatcher.updateObject(dataWatcherStart + 2, mana);
dataWatcher.set(START_MANA, mana);
}
@Override
public int getMinManaLoss() {
return dataWatcher.getWatchableObjectInt(dataWatcherStart + 3);
return dataWatcher.get(MIN_MANA_LOSS);
}
@Override
public void setMinManaLoss(int minManaLoss) {
dataWatcher.updateObject(dataWatcherStart + 3, minManaLoss);
dataWatcher.set(MIN_MANA_LOSS, minManaLoss);
}
@Override
public float getManaLossPerTick() {
return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 4);
return dataWatcher.get(MANA_LOSS_PER_TICK);
}
@Override
public void setManaLossPerTick(float mana) {
dataWatcher.updateObject(dataWatcherStart + 4, mana);
dataWatcher.set(MANA_LOSS_PER_TICK, mana);
}
@Override
public float getGravity() {
return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 5);
return dataWatcher.get(GRAVITY);
}
@Override
public void setGravity(float gravity) {
dataWatcher.updateObject(dataWatcherStart + 5, gravity);
dataWatcher.set(GRAVITY, gravity);
}
final int coordsStart = dataWatcherStart + 6;
@Override
public BlockPos getBurstSourceBlockPos() {
int x = dataWatcher.getWatchableObjectInt(coordsStart);
int y = dataWatcher.getWatchableObjectInt(coordsStart + 1);
int z = dataWatcher.getWatchableObjectInt(coordsStart + 2);
return new BlockPos(x, y, z);
return dataWatcher.get(SOURCE_COORDS);
}
@Override
public void setBurstSourceCoords(BlockPos pos) {
dataWatcher.updateObject(coordsStart, pos.getX());
dataWatcher.updateObject(coordsStart + 1, pos.getY());
dataWatcher.updateObject(coordsStart + 2, pos.getZ());
dataWatcher.set(SOURCE_COORDS, pos);
}
@Override
public ItemStack getSourceLens() {
return dataWatcher.getWatchableObjectItemStack(dataWatcherStart + 9);
Optional<ItemStack> stack = dataWatcher.get(SOURCE_LENS);
if(!stack.isPresent())
return new ItemStack(Blocks.stone, 0, 0); // todo 1.9 refact later
else return stack.get();
}
@Override
public void setSourceLens(ItemStack lens) {
dataWatcher.updateObject(dataWatcherStart + 9, lens == null ? new ItemStack(Blocks.stone, 0, 0) : lens);
dataWatcher.set(SOURCE_LENS, lens == null ? Optional.absent() : Optional.of(lens));
}
@Override
@@ -788,8 +793,6 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
return null;
}
final int motionStart = dataWatcherStart + 10;
@Override
public void setMotion(double x, double y, double z) {
motionX = x;
@@ -16,6 +16,8 @@ import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
@@ -65,9 +67,9 @@ public class EntityPinkWither extends EntityWither {
}
@Override
protected boolean interact(EntityPlayer player) {
protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) {
if(!player.isSneaking()) {
player.mountEntity(this);
player.startRiding(this);
return true;
}
return false;
@@ -16,6 +16,9 @@ import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.DamageSource;
@@ -34,6 +37,7 @@ public class EntityPoolMinecart extends EntityMinecart {
private static final int TRANSFER_RATE = 10000;
private static final String TAG_MANA = "mana";
private static final DataParameter<Integer> MANA = EntityDataManager.createKey(EntityPoolMinecart.class, DataSerializers.VARINT);
public EntityPoolMinecart(World p_i1712_1_) {
super(p_i1712_1_);
@@ -46,7 +50,7 @@ public class EntityPoolMinecart extends EntityMinecart {
@Override
protected void entityInit() {
super.entityInit();
dataWatcher.addObject(16, 0);
dataWatcher.register(MANA, 0);
}
@Override
@@ -153,11 +157,11 @@ public class EntityPoolMinecart extends EntityMinecart {
}
public int getMana() {
return dataWatcher.getWatchableObjectInt(16);
return dataWatcher.get(MANA);
}
public void setMana(int mana) {
dataWatcher.updateObject(16, mana);
dataWatcher.set(MANA, mana);
}
}
@@ -17,8 +17,12 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
@@ -32,6 +36,8 @@ import vazkii.botania.common.item.ModItems;
public class EntityThornChakram extends EntityThrowable {
private static final DataParameter<Integer> BOUNCES = EntityDataManager.createKey(EntityThornChakram.class, DataSerializers.VARINT);
private static final DataParameter<Boolean> FLARE = EntityDataManager.createKey(EntityThornChakram.class, DataSerializers.BOOLEAN);
private static final int MAX_BOUNCES = 16;
boolean bounced = false;
private ItemStack stack;
@@ -47,11 +53,9 @@ public class EntityThornChakram extends EntityThrowable {
@Override
protected void entityInit() {
dataWatcher.addObject(30, 0);
dataWatcher.addObject(31, (byte) 0);
dataWatcher.setObjectWatched(30);
dataWatcher.setObjectWatched(31);
super.entityInit();
dataWatcher.register(BOUNCES, 0);
dataWatcher.register(FLARE, false);
}
@Override
@@ -128,7 +132,7 @@ public class EntityThornChakram extends EntityThrowable {
if(fire)
pos.entityHit.setFire(5);
else if(worldObj.rand.nextInt(3) == 0)
((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0));
((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(MobEffects.poison, 60, 0));
} else if (pos.getBlockPos() != null) {
int bounces = getTimesBounced();
if(bounces < MAX_BOUNCES) {
@@ -151,19 +155,19 @@ public class EntityThornChakram extends EntityThrowable {
}
public int getTimesBounced() {
return dataWatcher.getWatchableObjectInt(30);
return dataWatcher.get(BOUNCES);
}
public void setTimesBounced(int times) {
dataWatcher.updateObject(30, times);
dataWatcher.set(BOUNCES, times);
}
public boolean isFire() {
return dataWatcher.getWatchableObjectByte(31) != 0;
return dataWatcher.get(FLARE);
}
public void setFire(boolean fire) {
dataWatcher.updateObject(31, (byte) (fire ? 1 : 0));
dataWatcher.set(FLARE, fire);
}
@Override
@@ -21,7 +21,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.relauncher.Side;
@@ -32,9 +36,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
// And we all know how much mods like deflecting EntityThrowables
public abstract class EntityThrowableCopy extends Entity implements IProjectile
{
private int xTile = -1;
private int yTile = -1;
private int zTile = -1;
private int xTile;
private int yTile;
private int zTile;
private Block inTile;
protected boolean inGround;
public int throwableShake;
@@ -43,13 +47,30 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
private String throwerName;
private int ticksInGround;
private int ticksInAir;
public Entity field_184539_c;
private int field_184540_av;
public EntityThrowableCopy(World worldIn)
{
super(worldIn);
this.xTile = -1;
this.yTile = -1;
this.zTile = -1;
this.setSize(0.25F, 0.25F);
}
public EntityThrowableCopy(World worldIn, double x, double y, double z)
{
this(worldIn);
this.setPosition(x, y, z);
}
public EntityThrowableCopy(World worldIn, EntityLivingBase throwerIn)
{
this(worldIn, throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight() - 0.10000000149011612D, throwerIn.posZ);
this.thrower = throwerIn;
}
protected void entityInit()
{
}
@@ -72,39 +93,19 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
return distance < d0 * d0;
}
public EntityThrowableCopy(World worldIn, EntityLivingBase throwerIn)
public void func_184538_a(Entity p_184538_1_, float p_184538_2_, float p_184538_3_, float p_184538_4_, float p_184538_5_, float p_184538_6_)
{
super(worldIn);
this.thrower = throwerIn;
this.setSize(0.25F, 0.25F);
this.setLocationAndAngles(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ, throwerIn.rotationYaw, throwerIn.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY -= 0.10000000149011612D;
this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.setPosition(this.posX, this.posY, this.posZ);
float f = 0.4F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.getInaccuracy()) / 180.0F * (float)Math.PI) * f);
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.getVelocity(), 1.0F);
}
float f = -MathHelper.sin(p_184538_3_ * 0.017453292F) * MathHelper.cos(p_184538_2_ * 0.017453292F);
float f1 = -MathHelper.sin((p_184538_2_ + p_184538_4_) * 0.017453292F);
float f2 = MathHelper.cos(p_184538_3_ * 0.017453292F) * MathHelper.cos(p_184538_2_ * 0.017453292F);
this.setThrowableHeading((double)f, (double)f1, (double)f2, p_184538_5_, p_184538_6_);
this.motionX += p_184538_1_.motionX;
this.motionZ += p_184538_1_.motionZ;
public EntityThrowableCopy(World worldIn, double x, double y, double z)
{
super(worldIn);
this.ticksInGround = 0;
this.setSize(0.25F, 0.25F);
this.setPosition(x, y, z);
}
protected float getVelocity()
{
return 1.5F;
}
protected float getInaccuracy()
{
return 0.0F;
if (!p_184538_1_.onGround)
{
this.motionY += p_184538_1_.motionY;
}
}
/**
@@ -126,13 +127,13 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.motionY = y;
this.motionZ = z;
float f1 = MathHelper.sqrt_double(x * x + z * z);
this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.atan2(x, z) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * 180.0D / Math.PI);
this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI));
this.ticksInGround = 0;
}
/**
* Sets the velocity to the args. Args: x, y, z
* Updates the velocity of the entity to a new value.
*/
@SideOnly(Side.CLIENT)
public void setVelocity(double x, double y, double z)
@@ -144,8 +145,8 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(x * x + z * z);
this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.atan2(x, z) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.atan2(y, (double)f) * 180.0D / Math.PI);
this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.atan2(y, (double)f) * (180D / Math.PI));
}
}
@@ -190,37 +191,46 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
++this.ticksInAir;
}
Vec3d vec3 = new Vec3d(this.posX, this.posY, this.posZ);
Vec3d vec31 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
RayTraceResult RayTraceResult = this.worldObj.rayTraceBlocks(vec3, vec31);
vec3 = new Vec3d(this.posX, this.posY, this.posZ);
vec31 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
Vec3d vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
RayTraceResult raytraceresult = this.worldObj.rayTraceBlocks(vec3d, vec3d1);
vec3d = new Vec3d(this.posX, this.posY, this.posZ);
vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (RayTraceResult != null)
if (raytraceresult != null)
{
vec31 = new Vec3d(RayTraceResult.hitVec.xCoord, RayTraceResult.hitVec.yCoord, RayTraceResult.hitVec.zCoord);
vec3d1 = new Vec3d(raytraceresult.hitVec.xCoord, raytraceresult.hitVec.yCoord, raytraceresult.hitVec.zCoord);
}
if (!this.worldObj.isRemote)
Entity entity = null;
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expandXyz(1.0D));
double d0 = 0.0D;
boolean flag = false;
for (int i = 0; i < list.size(); ++i)
{
Entity entity = null;
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
EntityLivingBase entitylivingbase = this.getThrower();
Entity entity1 = (Entity)list.get(i);
for (int j = 0; j < list.size(); ++j)
if (entity1.canBeCollidedWith())
{
Entity entity1 = list.get(j);
if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || this.ticksInAir >= 5))
if (entity1 == this.field_184539_c)
{
float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double)f, (double)f, (double)f);
RayTraceResult RayTraceResult1 = axisalignedbb.calculateIntercept(vec3, vec31);
flag = true;
}
else if (this.ticksExisted < 2 && this.field_184539_c == null)
{
this.field_184539_c = entity1;
flag = true;
}
else
{
flag = false;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expandXyz(0.30000001192092896D);
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (RayTraceResult1 != null)
if (raytraceresult1 != null)
{
double d1 = vec3.squareDistanceTo(RayTraceResult1.hitVec);
double d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
@@ -230,32 +240,44 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
}
}
}
}
if (entity != null)
if (this.field_184539_c != null)
{
if (flag)
{
RayTraceResult = new RayTraceResult(entity);
this.field_184540_av = 2;
}
else if (this.field_184540_av-- <= 0)
{
this.field_184539_c = null;
}
}
if (RayTraceResult != null)
if (entity != null)
{
if (RayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK && this.worldObj.getBlockState(RayTraceResult.getBlockPos()).getBlock() == Blocks.portal)
raytraceresult = new RayTraceResult(entity);
}
if (raytraceresult != null)
{
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && this.worldObj.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.portal)
{
this.setPortal(RayTraceResult.getBlockPos());
this.setPortal(raytraceresult.getBlockPos());
}
else
{
this.onImpact(RayTraceResult);
this.onImpact(raytraceresult);
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));
for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
@@ -277,24 +299,24 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f2 = 0.99F;
float f3 = this.getGravityVelocity();
float f1 = 0.99F;
float f2 = this.getGravityVelocity();
if (this.isInWater())
{
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 4; ++j)
{
float f4 = 0.25F;
this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ, new int[0]);
float f3 = 0.25F;
this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ, new int[0]);
}
f2 = 0.8F;
f1 = 0.8F;
}
this.motionX *= (double)f2;
this.motionY *= (double)f2;
this.motionZ *= (double)f2;
this.motionY -= (double)f3;
this.motionX *= (double)f1;
this.motionY *= (double)f1;
this.motionZ *= (double)f1;
this.motionY -= (double)f2;
this.setPosition(this.posX, this.posY, this.posZ);
}
@@ -309,53 +331,53 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected abstract void onImpact(RayTraceResult p_70184_1_);
protected abstract void onImpact(RayTraceResult result);
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
public void writeEntityToNBT(NBTTagCompound compound)
{
tagCompound.setShort("xTile", (short)this.xTile);
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
ResourceLocation resourcelocation = Block.blockRegistry.getNameForObject(this.inTile);
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setByte("shake", (byte)this.throwableShake);
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
compound.setInteger("xTile", this.xTile);
compound.setInteger("yTile", this.yTile);
compound.setInteger("zTile", this.zTile);
ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile);
compound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
compound.setByte("shake", (byte)this.throwableShake);
compound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower instanceof EntityPlayer)
if ((this.throwerName == null || this.throwerName.isEmpty()) && this.thrower instanceof EntityPlayer)
{
this.throwerName = this.thrower.getName();
}
tagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
compound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound tagCompund)
public void readEntityFromNBT(NBTTagCompound compound)
{
this.xTile = tagCompund.getShort("xTile");
this.yTile = tagCompund.getShort("yTile");
this.zTile = tagCompund.getShort("zTile");
this.xTile = compound.getInteger("xTile");
this.yTile = compound.getInteger("yTile");
this.zTile = compound.getInteger("zTile");
if (tagCompund.hasKey("inTile", 8))
if (compound.hasKey("inTile", 8))
{
this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
this.inTile = Block.getBlockFromName(compound.getString("inTile"));
}
else
{
this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
this.inTile = Block.getBlockById(compound.getByte("inTile") & 255);
}
this.throwableShake = tagCompund.getByte("shake") & 255;
this.inGround = tagCompund.getByte("inGround") == 1;
this.throwableShake = compound.getByte("shake") & 255;
this.inGround = compound.getByte("inGround") == 1;
this.thrower = null;
this.throwerName = tagCompund.getString("ownerName");
this.throwerName = compound.getString("ownerName");
if (this.throwerName != null && this.throwerName.length() == 0)
if (this.throwerName != null && this.throwerName.isEmpty())
{
this.throwerName = null;
}
@@ -365,7 +387,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
public EntityLivingBase getThrower()
{
if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0)
if (this.thrower == null && this.throwerName != null && !this.throwerName.isEmpty())
{
this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);
@@ -101,7 +101,7 @@ public class EntityThrownItem extends EntityItem {
if (RayTraceResult != null)
{
if (RayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK && worldObj.getBlockState(RayTraceResult.getBlockPos()).getBlock() == Blocks.portal)
if (RayTraceResult.typeOfHit == net.minecraft.util.math.RayTraceResult.Type.BLOCK && worldObj.getBlockState(RayTraceResult.getBlockPos()).getBlock() == Blocks.portal)
{
setPortal(RayTraceResult.getBlockPos());
}
@@ -17,6 +17,9 @@ import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.RayTraceResult;
@@ -27,16 +30,23 @@ import java.util.Map;
public class EntityVineBall extends EntityThrowable {
private static final DataParameter<Float> GRAVITY = EntityDataManager.createKey(EntityVineBall.class, DataSerializers.FLOAT);
private final boolean gravity;
public EntityVineBall(World par1World) {
super(par1World);
dataWatcher.addObject(30, 0F);
dataWatcher.setObjectWatched(30);
gravity = false;
}
public EntityVineBall(EntityPlayer player, boolean gravity) {
super(player.worldObj, player);
dataWatcher.addObject(30, gravity ? 0.03F : 0F);
dataWatcher.setObjectWatched(30);
this.gravity = gravity;
}
@Override
protected void entityInit() {
super.entityInit();
dataWatcher.register(GRAVITY, gravity ? 0.03F : 0F);
}
@Override
@@ -50,11 +60,12 @@ public class EntityVineBall extends EntityThrowable {
if(dir != null && dir.getAxis() != EnumFacing.Axis.Y) {
BlockPos pos = var1.getBlockPos().offset(dir);
while(pos.getY() > 0) {
Block block = worldObj.getBlockState(pos).getBlock();
if(block.isAir(worldObj, pos)) {
IBlockState state = ModBlocks.solidVines.getDefaultState().withProperty(propMap.get(dir.getOpposite()), true);
worldObj.setBlockState(pos, state, 1 | 2);
worldObj.playAuxSFX(2001, pos, Block.getStateId(state));
IBlockState state = worldObj.getBlockState(pos);
Block block = state.getBlock();
if(block.isAir(state, worldObj, pos)) {
IBlockState stateSet = ModBlocks.solidVines.getDefaultState().withProperty(propMap.get(dir.getOpposite()), true);
worldObj.setBlockState(pos, stateSet, 1 | 2);
worldObj.playAuxSFX(2001, pos, Block.getStateId(stateSet));
pos = pos.down();
} else break;
}
@@ -67,7 +78,7 @@ public class EntityVineBall extends EntityThrowable {
@Override
protected float getGravityVelocity() {
return dataWatcher.getWatchableObjectFloat(30);
return dataWatcher.get(GRAVITY);
}
}
@@ -25,6 +25,7 @@ import vazkii.botania.api.internal.IGuiLexiconEntry;
import vazkii.botania.api.lexicon.ILexicon;
import vazkii.botania.api.lexicon.ITwoNamedPage;
import vazkii.botania.api.recipe.RecipeBrew;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.item.ModItems;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -56,8 +57,8 @@ public class PageBrew extends PageRecipe implements ITwoNamedPage {
renderer.setUnicodeFlag(unicode);
PageText.renderText(x, y + 22, width, height, text);
ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
if(book != null && book.getItem() instanceof ILexicon && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, BotaniaAPI.elvenKnowledge)) {
ItemStack book = PlayerHelper.getFirstHeldItemClass(Minecraft.getMinecraft().thePlayer, ILexicon.class);
if(book != null && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, BotaniaAPI.elvenKnowledge)) {
renderItemAtLinePos(gui, 20, 2, y + 12, recipe.getOutput(new ItemStack(ModItems.vial)));
renderItemAtLinePos(gui, 20, 3, y + 12, recipe.getOutput(new ItemStack(ModItems.vial, 1, 1)));
} else renderItemAtLinePos(gui, 0, -1, y + 12, recipe.getOutput(new ItemStack(ModItems.vial)));