mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed changelings being able to disguise themselves as various weather effects
This commit is contained in:
parent
c02c72cc60
commit
38daa43291
5 changed files with 44 additions and 6 deletions
|
@ -58,7 +58,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityCloud extends EntityFlying implements IAnimals {
|
||||
public class EntityCloud extends EntityFlying implements IAnimals, IInAnimate {
|
||||
|
||||
private static final DataParameter<Integer> RAINTIMER = EntityDataManager.createKey(EntityCloud.class, DataSerializers.VARINT);
|
||||
private static final DataParameter<Boolean> THUNDERING = EntityDataManager.createKey(EntityCloud.class, DataSerializers.BOOLEAN);
|
||||
|
@ -145,6 +145,11 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
|||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteract(Race race) {
|
||||
return race.canInteractWithClouds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStruckByLightning(EntityLightningBolt lightningBolt) {
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.effect.EntityWeatherEffect;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -9,7 +11,7 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome.SpawnListEntry;
|
||||
|
||||
public class EntityRainbow extends EntityWeatherEffect {
|
||||
public class EntityRainbow extends EntityWeatherEffect implements IInAnimate {
|
||||
|
||||
public static final SpawnListEntry SPAWN_ENTRY = new SpawnListEntry(EntityRainbow.Spawner.class, 1, 1, 1);
|
||||
|
||||
|
@ -45,6 +47,11 @@ public class EntityRainbow extends EntityWeatherEffect {
|
|||
return pass == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteract(Race race) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z) {
|
||||
posX = x;
|
||||
|
|
|
@ -5,6 +5,7 @@ import javax.annotation.Nullable;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import com.minelittlepony.unicopia.item.ICastable;
|
||||
import com.minelittlepony.unicopia.network.EffectSync;
|
||||
|
@ -34,7 +35,7 @@ import net.minecraft.util.SoundCategory;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntitySpell extends EntityLiving implements IMagicals, ICaster<EntityLivingBase> {
|
||||
public class EntitySpell extends EntityLiving implements IMagicals, ICaster<EntityLivingBase>, IInAnimate {
|
||||
|
||||
private EntityLivingBase owner = null;
|
||||
|
||||
|
@ -89,6 +90,11 @@ public class EntitySpell extends EntityLiving implements IMagicals, ICaster<Enti
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteract(Race race) {
|
||||
return race.canCast();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMagicEffect getEffect(boolean update) {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
|
||||
/**
|
||||
* This interface is for any entities that are categorised as inanimated,
|
||||
* or part of a terrain effect.
|
||||
*
|
||||
* These typically can't be interacted with by players unless under certain cirumstances.
|
||||
*
|
||||
*/
|
||||
public interface IInAnimate {
|
||||
boolean canInteract(Race race);
|
||||
}
|
|
@ -5,7 +5,9 @@ import javax.annotation.Nullable;
|
|||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.IInAnimate;
|
||||
import com.minelittlepony.unicopia.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
||||
import com.minelittlepony.unicopia.power.data.Hit;
|
||||
|
@ -15,6 +17,7 @@ import com.minelittlepony.util.vector.VecHelper;
|
|||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.effect.EntityWeatherEffect;
|
||||
import net.minecraft.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
|
@ -43,7 +46,8 @@ public class PowerDisguise extends PowerFeed {
|
|||
public void apply(IPlayer iplayer, Hit data) {
|
||||
EntityPlayer player = iplayer.getOwner();
|
||||
RayTraceResult trace = VecHelper.getObjectMouseOver(player, 10, 1);
|
||||
Entity looked = null;
|
||||
|
||||
Entity looked = trace.entityHit;
|
||||
|
||||
if (trace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
IBlockState state = player.getEntityWorld().getBlockState(trace.getBlockPos());
|
||||
|
@ -51,8 +55,10 @@ public class PowerDisguise extends PowerFeed {
|
|||
if (!state.getBlock().isAir(state, player.getEntityWorld(), trace.getBlockPos())) {
|
||||
looked = new EntityFallingBlock(player.getEntityWorld(), 0, 0, 0, state);
|
||||
}
|
||||
} else {
|
||||
looked = trace.entityHit;
|
||||
}
|
||||
|
||||
if (looked instanceof EntityWeatherEffect || (looked instanceof IInAnimate && !((IInAnimate)looked).canInteract(Race.CHANGELING))) {
|
||||
looked = null;
|
||||
}
|
||||
|
||||
if (looked instanceof EntityPlayer) {
|
||||
|
|
Loading…
Reference in a new issue