mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-25 06:04:32 +01:00
Fixed changeling traps spawning slime layers in the air
This commit is contained in:
parent
a363e22b28
commit
dc9c409a9b
1 changed files with 22 additions and 12 deletions
|
@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.init.USounds;
|
||||||
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
||||||
import com.minelittlepony.util.WorldEvent;
|
import com.minelittlepony.util.WorldEvent;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
@ -75,7 +76,8 @@ public class SpellChangelingTrap extends AbstractSpell implements ITossedEffect,
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!caster.getWorld().isRemote && checkStruggleCondition(caster)) {
|
if (caster.isLocal()) {
|
||||||
|
if (checkStruggleCondition(caster)) {
|
||||||
previousTrappedPosition = origin;
|
previousTrappedPosition = origin;
|
||||||
struggleCounter--;
|
struggleCounter--;
|
||||||
WorldEvent.DESTROY_BLOCK.play(caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState());
|
WorldEvent.DESTROY_BLOCK.play(caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState());
|
||||||
|
@ -83,12 +85,20 @@ public class SpellChangelingTrap extends AbstractSpell implements ITossedEffect,
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caster.getWorld().isAirBlock(origin) || caster.getWorld().getBlockState(origin).getBlock().isReplaceable(caster.getWorld(), origin)) {
|
Block block = caster.getWorld().getBlockState(origin).getBlock();
|
||||||
|
|
||||||
|
if (UBlocks.slime_layer.canPlaceBlockAt(caster.getWorld(), origin)) {
|
||||||
|
if (caster.getWorld().isAirBlock(origin) || (block != UBlocks.slime_layer && block.isReplaceable(caster.getWorld(), origin))) {
|
||||||
caster.getWorld().setBlockState(origin, UBlocks.slime_layer.getDefaultState());
|
caster.getWorld().setBlockState(origin, UBlocks.slime_layer.getDefaultState());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
entity.motionX = 0;
|
entity.motionX = 0;
|
||||||
|
|
||||||
|
if (!entity.onGround && entity.motionY > 0) {
|
||||||
entity.motionY = 0;
|
entity.motionY = 0;
|
||||||
|
}
|
||||||
entity.motionZ = 0;
|
entity.motionZ = 0;
|
||||||
|
|
||||||
entity.moveForward = 0;
|
entity.moveForward = 0;
|
||||||
|
@ -112,7 +122,7 @@ public class SpellChangelingTrap extends AbstractSpell implements ITossedEffect,
|
||||||
|
|
||||||
entity.addPotionEffect(SLIME_REGEN);
|
entity.addPotionEffect(SLIME_REGEN);
|
||||||
|
|
||||||
if (caster.getWorld().isRemote) {
|
if (caster.isLocal()) {
|
||||||
if (struggleCounter <= 0) {
|
if (struggleCounter <= 0) {
|
||||||
setDead();
|
setDead();
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
|
@ -121,12 +131,12 @@ public class SpellChangelingTrap extends AbstractSpell implements ITossedEffect,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return struggleCounter > 0;
|
return !entity.isRiding() && struggleCounter > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(ICaster<?> source) {
|
public boolean update(ICaster<?> source) {
|
||||||
return true;
|
return !source.getEntity().isRiding();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue