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