Fix indentation. What the hell!?

This commit is contained in:
Sollace 2019-02-21 19:27:34 +02:00
parent ce77b6f140
commit c3029fe107

View file

@ -38,39 +38,39 @@ import net.minecraft.world.World;
public class EntitySpell extends EntityCreature implements IMagicals, ICaster<EntityLivingBase>, IInAnimate { public class EntitySpell extends EntityCreature implements IMagicals, ICaster<EntityLivingBase>, IInAnimate {
private EntityLivingBase owner = null; private EntityLivingBase owner = null;
public float hoverStart; public float hoverStart;
private static final DataParameter<Integer> LEVEL = EntityDataManager private static final DataParameter<Integer> LEVEL = EntityDataManager
.createKey(EntitySpell.class, DataSerializers.VARINT); .createKey(EntitySpell.class, DataSerializers.VARINT);
private static final DataParameter<String> OWNER = EntityDataManager private static final DataParameter<String> OWNER = EntityDataManager
.createKey(EntitySpell.class, DataSerializers.STRING); .createKey(EntitySpell.class, DataSerializers.STRING);
private static final DataParameter<NBTTagCompound> EFFECT = EntityDataManager private static final DataParameter<NBTTagCompound> EFFECT = EntityDataManager
.createKey(EntitySpell.class, DataSerializers.COMPOUND_TAG); .createKey(EntitySpell.class, DataSerializers.COMPOUND_TAG);
private static final DataParameter<Integer> AFFINITY = EntityDataManager private static final DataParameter<Integer> AFFINITY = EntityDataManager
.createKey(EntitySpell.class, DataSerializers.VARINT); .createKey(EntitySpell.class, DataSerializers.VARINT);
private final EffectSync<EntityLivingBase> effectDelegate = new EffectSync<>(this, EFFECT); private final EffectSync<EntityLivingBase> effectDelegate = new EffectSync<>(this, EFFECT);
public EntitySpell(World w) { public EntitySpell(World w) {
super(w); super(w);
setSize(0.6f, 0.25f); setSize(0.6f, 0.25f);
hoverStart = (float)(Math.random() * Math.PI * 2.0D); hoverStart = (float)(Math.random() * Math.PI * 2.0D);
setRenderDistanceWeight(getRenderDistanceWeight() + 1); setRenderDistanceWeight(getRenderDistanceWeight() + 1);
preventEntitySpawning = false; preventEntitySpawning = false;
enablePersistence(); enablePersistence();
} }
@Override @Override
public boolean isInRangeToRenderDist(double distance) { public boolean isInRangeToRenderDist(double distance) {
if (getCurrentLevel() > 0) { if (getCurrentLevel() > 0) {
distance /= getCurrentLevel(); distance /= getCurrentLevel();
} }
return super.isInRangeToRenderDist(distance); return super.isInRangeToRenderDist(distance);
} }
@Override @Override
@ -82,23 +82,23 @@ public class EntitySpell extends EntityCreature implements IMagicals, ICaster<En
dataManager.set(AFFINITY, affinity.ordinal()); dataManager.set(AFFINITY, affinity.ordinal());
} }
@Override @Override
public void setEffect(@Nullable IMagicEffect effect) { public void setEffect(@Nullable IMagicEffect effect) {
effectDelegate.set(effect); effectDelegate.set(effect);
if (effect != null) { if (effect != null) {
effect.onPlaced(this); effect.onPlaced(this);
} }
} }
@Override @Override
public boolean canInteract(Race race) { public boolean canInteract(Race race) {
return race.canCast(); return race.canCast();
} }
@Nullable @Nullable
@Override @Override
public <T extends IMagicEffect> T getEffect(@Nullable Class<T> type, boolean update) { public <T extends IMagicEffect> T getEffect(@Nullable Class<T> type, boolean update) {
return effectDelegate.get(type, update); return effectDelegate.get(type, update);
} }
@ -107,27 +107,27 @@ public class EntitySpell extends EntityCreature implements IMagicals, ICaster<En
return effectDelegate.has(); return effectDelegate.has();
} }
@Override @Override
protected void entityInit() { protected void entityInit() {
super.entityInit(); super.entityInit();
dataManager.register(LEVEL, 0); dataManager.register(LEVEL, 0);
dataManager.register(EFFECT, new NBTTagCompound()); dataManager.register(EFFECT, new NBTTagCompound());
dataManager.register(OWNER, ""); dataManager.register(OWNER, "");
dataManager.register(AFFINITY, SpellAffinity.NEUTRAL.ordinal()); dataManager.register(AFFINITY, SpellAffinity.NEUTRAL.ordinal());
} }
@Override @Override
public ItemStack getPickedResult(RayTraceResult target) { public ItemStack getPickedResult(RayTraceResult target) {
return SpellRegistry.instance().enchantStack(new ItemStack(getItem()), getEffect().getName()); return SpellRegistry.instance().enchantStack(new ItemStack(getItem()), getEffect().getName());
} }
protected Item getItem() { protected Item getItem() {
return getAffinity() == SpellAffinity.BAD ? UItems.curse : UItems.spell; return getAffinity() == SpellAffinity.BAD ? UItems.curse : UItems.spell;
} }
@Override @Override
protected boolean canTriggerWalking() { protected boolean canTriggerWalking() {
return false; return false;
} }
@Override @Override
@ -141,74 +141,74 @@ public class EntitySpell extends EntityCreature implements IMagicals, ICaster<En
} }
@Override @Override
public void setOwner(EntityLivingBase owner) { public void setOwner(EntityLivingBase owner) {
this.owner = owner; this.owner = owner;
setOwner(owner.getName()); setOwner(owner.getName());
} }
protected void setOwner(String ownerName) { protected void setOwner(String ownerName) {
if (!StringUtils.isEmpty(ownerName)) { if (!StringUtils.isEmpty(ownerName)) {
dataManager.set(OWNER, ownerName); dataManager.set(OWNER, ownerName);
} }
} }
protected String getOwnerName() { protected String getOwnerName() {
String ownerName = dataManager.get(OWNER); String ownerName = dataManager.get(OWNER);
if (!StringUtils.isEmpty(ownerName)) { if (!StringUtils.isEmpty(ownerName)) {
if (owner instanceof EntityPlayer) { if (owner instanceof EntityPlayer) {
return owner.getName(); return owner.getName();
} }
return ""; return "";
} }
return ownerName; return ownerName;
} }
@Override @Override
public EntityLivingBase getOwner() { public EntityLivingBase getOwner() {
if (owner == null) { if (owner == null) {
String ownerName = dataManager.get(OWNER); String ownerName = dataManager.get(OWNER);
if (ownerName != null && ownerName.length() > 0) { if (ownerName != null && ownerName.length() > 0) {
owner = world.getPlayerEntityByName(ownerName); owner = world.getPlayerEntityByName(ownerName);
} }
} }
return owner; return owner;
} }
protected void displayTick() { protected void displayTick() {
if (hasEffect()) { if (hasEffect()) {
getEffect().render(this); getEffect().render(this);
} }
} }
@Override @Override
public void onUpdate() { public void onUpdate() {
if (world.isRemote) { if (world.isRemote) {
displayTick(); displayTick();
} }
if (!hasEffect()) { if (!hasEffect()) {
setDead(); setDead();
} else { } else {
if (getEffect().getDead()) { if (getEffect().getDead()) {
setDead(); setDead();
onDeath(); onDeath();
} else { } else {
getEffect().update(this); getEffect().update(this);
} }
if (getEffect().allowAI()) { if (getEffect().allowAI()) {
super.onUpdate(); super.onUpdate();
} }
} }
if (overLevelCap()) { if (overLevelCap()) {
if (world.rand.nextInt(10) == 0) { if (world.rand.nextInt(10) == 0) {
spawnExplosionParticle(); spawnExplosionParticle();
} }
if (!world.isRemote && hasEffect()) { if (!world.isRemote && hasEffect()) {
float exhaustionChance = getEffect().getExhaustion(this); float exhaustionChance = getEffect().getExhaustion(this);
@ -222,86 +222,86 @@ public class EntitySpell extends EntityCreature implements IMagicals, ICaster<En
setDead(); setDead();
} }
} }
} }
if (getCurrentLevel() < 0) { if (getCurrentLevel() < 0) {
setDead(); setDead();
} }
}
@Override
public void fall(float distance, float damageMultiplier) {
}
public boolean overLevelCap() {
return getCurrentLevel() > getMaxLevel();
}
@Override
protected void updateFallState(double y, boolean onGround, IBlockState state, BlockPos pos) {
this.onGround = true;
//super.updateFallState(y, onGround = this.onGround = true, state, pos);
} }
@Override @Override
public boolean attackEntityFrom(DamageSource source, float amount) { public void fall(float distance, float damageMultiplier) {
if (!world.isRemote) {
setDead();
onDeath();
}
return false;
}
protected void onDeath() { }
SoundType sound = SoundType.STONE;
world.playSound(posX, posY, posZ, sound.getBreakSound(), SoundCategory.NEUTRAL, sound.getVolume(), sound.getPitch(), true); public boolean overLevelCap() {
return getCurrentLevel() > getMaxLevel();
}
if (world.getGameRules().getBoolean("doTileDrops")) { @Override
int level = getCurrentLevel(); protected void updateFallState(double y, boolean onGround, IBlockState state, BlockPos pos) {
this.onGround = true;
//super.updateFallState(y, onGround = this.onGround = true, state, pos);
}
ItemStack stack = new ItemStack(getItem(), level + 1); @Override
if (hasEffect()) { public boolean attackEntityFrom(DamageSource source, float amount) {
SpellRegistry.instance().enchantStack(stack, getEffect().getName()); if (!world.isRemote) {
} setDead();
onDeath();
}
return false;
}
entityDropItem(stack, 0); protected void onDeath() {
} SoundType sound = SoundType.STONE;
}
@Override world.playSound(posX, posY, posZ, sound.getBreakSound(), SoundCategory.NEUTRAL, sound.getVolume(), sound.getPitch(), true);
public void setDead() {
if (hasEffect()) {
getEffect().setDead();
}
super.setDead();
}
@Override if (world.getGameRules().getBoolean("doTileDrops")) {
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) { int level = getCurrentLevel();
if (Predicates.MAGI.test(player)) {
ItemStack currentItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (currentItem != null ItemStack stack = new ItemStack(getItem(), level + 1);
&& currentItem.getItem() instanceof ICastable if (hasEffect()) {
&& ((ICastable)currentItem.getItem()).canFeed(this, currentItem) SpellRegistry.instance().enchantStack(stack, getEffect().getName());
&& tryLevelUp(currentItem)) { }
if (!player.capabilities.isCreativeMode) { entityDropItem(stack, 0);
currentItem.shrink(1); }
}
if (currentItem.isEmpty()) { @Override
player.renderBrokenItemStack(currentItem); public void setDead() {
} if (hasEffect()) {
} getEffect().setDead();
}
super.setDead();
}
return EnumActionResult.SUCCESS; @Override
} public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
} if (Predicates.MAGI.test(player)) {
ItemStack currentItem = player.getHeldItem(EnumHand.MAIN_HAND);
return EnumActionResult.FAIL; if (currentItem != null
} && currentItem.getItem() instanceof ICastable
&& ((ICastable)currentItem.getItem()).canFeed(this, currentItem)
&& tryLevelUp(currentItem)) {
if (!player.capabilities.isCreativeMode) {
currentItem.shrink(1);
if (currentItem.isEmpty()) {
player.renderBrokenItemStack(currentItem);
}
}
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.FAIL;
}
public boolean tryLevelUp(ItemStack stack) { public boolean tryLevelUp(ItemStack stack) {
if (hasEffect() && SpellRegistry.stackHasEnchantment(stack)) { if (hasEffect() && SpellRegistry.stackHasEnchantment(stack)) {
@ -319,51 +319,51 @@ public class EntitySpell extends EntityCreature implements IMagicals, ICaster<En
return false; return false;
} }
@Override @Override
public int getMaxLevel() { public int getMaxLevel() {
return hasEffect() ? getEffect().getMaxLevelCutOff(this) : 0; return hasEffect() ? getEffect().getMaxLevelCutOff(this) : 0;
} }
@Override @Override
public int getCurrentLevel() { public int getCurrentLevel() {
return dataManager.get(LEVEL); return dataManager.get(LEVEL);
} }
@Override @Override
public void setCurrentLevel(int level) { public void setCurrentLevel(int level) {
dataManager.set(LEVEL, Math.max(level, 0)); dataManager.set(LEVEL, Math.max(level, 0));
} }
@Override @Override
public Entity getEntity() { public Entity getEntity() {
return this; return this;
} }
@Override @Override
public void readEntityFromNBT(NBTTagCompound compound) { public void readEntityFromNBT(NBTTagCompound compound) {
super.readEntityFromNBT(compound); super.readEntityFromNBT(compound);
if (compound.hasKey("affinity")) { if (compound.hasKey("affinity")) {
setAffinity(SpellAffinity.of(compound.getString("affinity"))); setAffinity(SpellAffinity.of(compound.getString("affinity")));
} }
setOwner(compound.getString("ownerName")); setOwner(compound.getString("ownerName"));
setCurrentLevel(compound.getInteger("level")); setCurrentLevel(compound.getInteger("level"));
if (compound.hasKey("effect")) { if (compound.hasKey("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompoundTag("effect"))); setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompoundTag("effect")));
} }
} }
@Override @Override
public void writeEntityToNBT(NBTTagCompound compound) { public void writeEntityToNBT(NBTTagCompound compound) {
super.writeEntityToNBT(compound); super.writeEntityToNBT(compound);
compound.setString("affinity", getAffinity().name()); compound.setString("affinity", getAffinity().name());
compound.setString("ownerName", getOwnerName()); compound.setString("ownerName", getOwnerName());
compound.setInteger("level", getCurrentLevel()); compound.setInteger("level", getCurrentLevel());
if (hasEffect()) { if (hasEffect()) {
compound.setTag("effect", SpellRegistry.instance().serializeEffectToNBT(getEffect())); compound.setTag("effect", SpellRegistry.instance().serializeEffectToNBT(getEffect()));
} }
} }
} }