mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Fixed indentation
This commit is contained in:
parent
a367bd57d9
commit
42b856aa3d
1 changed files with 110 additions and 110 deletions
|
@ -28,27 +28,27 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
public class SpellPortal extends AbstractSpell implements IUseAction {
|
public class SpellPortal extends AbstractSpell implements IUseAction {
|
||||||
|
|
||||||
private static final IShape portalZone_X = new Sphere(true, 1, 0, 2, 1);
|
private static final IShape portalZone_X = new Sphere(true, 1, 0, 2, 1);
|
||||||
private static final IShape portalZone_Y = new Sphere(true, 1, 2, 0, 2);
|
private static final IShape portalZone_Y = new Sphere(true, 1, 2, 0, 2);
|
||||||
private static final IShape portalZone_Z = new Sphere(true, 1, 1, 2, 0);
|
private static final IShape portalZone_Z = new Sphere(true, 1, 1, 2, 0);
|
||||||
|
|
||||||
private static final AxisAlignedBB TELEPORT_BOUNDS_VERT = new AxisAlignedBB(-1, -0.5, -1, 1, 0.5, 1);
|
private static final AxisAlignedBB TELEPORT_BOUNDS_VERT = new AxisAlignedBB(-1, -0.5, -1, 1, 0.5, 1);
|
||||||
private static final AxisAlignedBB TELEPORT_BOUNDS = new AxisAlignedBB(-0.5, -0.5, -0.5, 0.5, 3, 0.5);
|
private static final AxisAlignedBB TELEPORT_BOUNDS = new AxisAlignedBB(-0.5, -0.5, -0.5, 0.5, 3, 0.5);
|
||||||
|
|
||||||
private static final AxisAlignedBB DESTINATION_BOUNDS = new AxisAlignedBB(0, 0, 0, 1.5F, 1.5F, 1.5F);
|
private static final AxisAlignedBB DESTINATION_BOUNDS = new AxisAlignedBB(0, 0, 0, 1.5F, 1.5F, 1.5F);
|
||||||
|
|
||||||
private int cooldown = 0;
|
private int cooldown = 0;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private SpellPortal sibling = null;
|
private SpellPortal sibling = null;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private BlockPos position = null;
|
private BlockPos position = null;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private BlockPos destinationPos = null;
|
private BlockPos destinationPos = null;
|
||||||
|
|
||||||
private EnumFacing.Axis axis = EnumFacing.Axis.Y;
|
private EnumFacing.Axis axis = EnumFacing.Axis.Y;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -60,54 +60,54 @@ public class SpellPortal extends AbstractSpell implements IUseAction {
|
||||||
return 0x384C38;
|
return 0x384C38;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDead() {
|
public void setDead() {
|
||||||
super.setDead();
|
super.setDead();
|
||||||
|
|
||||||
if (sibling != null && !sibling.getDead()) {
|
if (sibling != null && !sibling.getDead()) {
|
||||||
sibling.setDead();
|
sibling.setDead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
position = pos.offset(side);
|
position = pos.offset(side);
|
||||||
axis = EnumFacing.getDirectionFromEntityLiving(position, player).getAxis();
|
axis = EnumFacing.getDirectionFromEntityLiving(position, player).getAxis();
|
||||||
|
|
||||||
IPlayer prop = PlayerSpeciesList.instance().getPlayer(player);
|
IPlayer prop = PlayerSpeciesList.instance().getPlayer(player);
|
||||||
|
|
||||||
IMagicEffect other = prop.getEffect();
|
IMagicEffect other = prop.getEffect();
|
||||||
if (other instanceof SpellPortal && other != this && !other.getDead()) {
|
if (other instanceof SpellPortal && other != this && !other.getDead()) {
|
||||||
((SpellPortal)other).notifyMatched(this);
|
((SpellPortal)other).notifyMatched(this);
|
||||||
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
prop.setEffect(null);
|
prop.setEffect(null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
prop.setEffect(this);
|
prop.setEffect(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SpellCastResult.PLACE;
|
return SpellCastResult.PLACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity) {
|
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity) {
|
||||||
return SpellCastResult.NONE;
|
return SpellCastResult.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyMatched(SpellPortal other) {
|
public void notifyMatched(SpellPortal other) {
|
||||||
if (sibling == null) {
|
if (sibling == null) {
|
||||||
sibling = other;
|
sibling = other;
|
||||||
other.sibling = this;
|
other.sibling = this;
|
||||||
|
|
||||||
sibling.destinationPos = position;
|
sibling.destinationPos = position;
|
||||||
destinationPos = sibling.position;
|
destinationPos = sibling.position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateOnPerson(ICaster<?> caster) {
|
public boolean updateOnPerson(ICaster<?> caster) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -137,26 +137,26 @@ public class SpellPortal extends AbstractSpell implements IUseAction {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IShape getPortalZone() {
|
public IShape getPortalZone() {
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case X: return portalZone_X;
|
case X: return portalZone_X;
|
||||||
default:
|
default:
|
||||||
case Y: return portalZone_Y;
|
case Y: return portalZone_Y;
|
||||||
case Z: return portalZone_Z;
|
case Z: return portalZone_Z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBB getTeleportBounds() {
|
public AxisAlignedBB getTeleportBounds() {
|
||||||
if (axis == EnumFacing.Axis.Y) {
|
if (axis == EnumFacing.Axis.Y) {
|
||||||
return TELEPORT_BOUNDS_VERT;
|
return TELEPORT_BOUNDS_VERT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TELEPORT_BOUNDS;
|
return TELEPORT_BOUNDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean teleportNear(ICaster<?> source, int level) {
|
private boolean teleportNear(ICaster<?> source, int level) {
|
||||||
return source.getWorld().getEntitiesWithinAABB(Entity.class, getTeleportBounds().offset(source.getOrigin())).stream().filter(i -> {
|
return source.getWorld().getEntitiesWithinAABB(Entity.class, getTeleportBounds().offset(source.getOrigin())).stream().filter(i -> {
|
||||||
if (!(i instanceof IMagicals) && i.timeUntilPortal == 0) {
|
if (!(i instanceof IMagicals) && i.timeUntilPortal == 0) {
|
||||||
EnumFacing.Axis xi = i.getHorizontalFacing().getAxis();
|
EnumFacing.Axis xi = i.getHorizontalFacing().getAxis();
|
||||||
|
|
||||||
if (axis != EnumFacing.Axis.Y && xi != axis) {
|
if (axis != EnumFacing.Axis.Y && xi != axis) {
|
||||||
|
@ -194,58 +194,58 @@ public class SpellPortal extends AbstractSpell implements IUseAction {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}).count() > 0;
|
}).count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<SpellPortal> getDestinationPortal(World w) {
|
public Optional<SpellPortal> getDestinationPortal(World w) {
|
||||||
if (sibling == null && destinationPos != null) {
|
if (sibling == null && destinationPos != null) {
|
||||||
w.getBlockLightOpacity(destinationPos);
|
w.getBlockLightOpacity(destinationPos);
|
||||||
w.getEntitiesWithinAABB(EntitySpell.class, DESTINATION_BOUNDS.offset(destinationPos)).stream()
|
w.getEntitiesWithinAABB(EntitySpell.class, DESTINATION_BOUNDS.offset(destinationPos)).stream()
|
||||||
.filter(i -> i.getEffect() instanceof SpellPortal)
|
.filter(i -> i.getEffect() instanceof SpellPortal)
|
||||||
.map(i -> (SpellPortal)i.getEffect())
|
.map(i -> (SpellPortal)i.getEffect())
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(s -> sibling = s);
|
.ifPresent(s -> sibling = s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.ofNullable(sibling);
|
return Optional.ofNullable(sibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound compound) {
|
public void writeToNBT(NBTTagCompound compound) {
|
||||||
if (destinationPos != null) {
|
if (destinationPos != null) {
|
||||||
NBTTagCompound dest = new NBTTagCompound();
|
NBTTagCompound dest = new NBTTagCompound();
|
||||||
|
|
||||||
dest.setInteger("X", destinationPos.getX());
|
dest.setInteger("X", destinationPos.getX());
|
||||||
dest.setInteger("Y", destinationPos.getY());
|
dest.setInteger("Y", destinationPos.getY());
|
||||||
dest.setInteger("Z", destinationPos.getZ());
|
dest.setInteger("Z", destinationPos.getZ());
|
||||||
|
|
||||||
compound.setTag("destination", dest);
|
compound.setTag("destination", dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
compound.setString("axis", axis.getName2());
|
compound.setString("axis", axis.getName2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
if (compound.hasKey("destination")) {
|
if (compound.hasKey("destination")) {
|
||||||
NBTTagCompound dest = compound.getCompoundTag("destination");
|
NBTTagCompound dest = compound.getCompoundTag("destination");
|
||||||
|
|
||||||
destinationPos = new BlockPos(
|
destinationPos = new BlockPos(
|
||||||
dest.getInteger("X"),
|
dest.getInteger("X"),
|
||||||
dest.getInteger("Y"),
|
dest.getInteger("Y"),
|
||||||
dest.getInteger("Z")
|
dest.getInteger("Z")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compound.hasKey("axis")) {
|
if (compound.hasKey("axis")) {
|
||||||
axis = EnumFacing.Axis.byName(compound.getString("axis").toLowerCase(Locale.ROOT));
|
axis = EnumFacing.Axis.byName(compound.getString("axis").toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
if (axis == null) {
|
if (axis == null) {
|
||||||
axis = EnumFacing.Axis.Y;
|
axis = EnumFacing.Axis.Y;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
axis = EnumFacing.Axis.Y;
|
axis = EnumFacing.Axis.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue