mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +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 {
|
||||
|
||||
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_Z = new Sphere(true, 1, 1, 2, 0);
|
||||
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_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 = 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 int cooldown = 0;
|
||||
private int cooldown = 0;
|
||||
|
||||
@Nullable
|
||||
private SpellPortal sibling = null;
|
||||
@Nullable
|
||||
private SpellPortal sibling = null;
|
||||
|
||||
@Nullable
|
||||
private BlockPos position = null;
|
||||
@Nullable
|
||||
private BlockPos position = null;
|
||||
|
||||
@Nullable
|
||||
private BlockPos destinationPos = null;
|
||||
@Nullable
|
||||
private BlockPos destinationPos = null;
|
||||
|
||||
private EnumFacing.Axis axis = EnumFacing.Axis.Y;
|
||||
private EnumFacing.Axis axis = EnumFacing.Axis.Y;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -60,54 +60,54 @@ public class SpellPortal extends AbstractSpell implements IUseAction {
|
|||
return 0x384C38;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDead() {
|
||||
super.setDead();
|
||||
@Override
|
||||
public void setDead() {
|
||||
super.setDead();
|
||||
|
||||
if (sibling != null && !sibling.getDead()) {
|
||||
sibling.setDead();
|
||||
}
|
||||
}
|
||||
if (sibling != null && !sibling.getDead()) {
|
||||
sibling.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
axis = EnumFacing.getDirectionFromEntityLiving(position, player).getAxis();
|
||||
@Override
|
||||
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);
|
||||
axis = EnumFacing.getDirectionFromEntityLiving(position, player).getAxis();
|
||||
|
||||
IPlayer prop = PlayerSpeciesList.instance().getPlayer(player);
|
||||
IPlayer prop = PlayerSpeciesList.instance().getPlayer(player);
|
||||
|
||||
IMagicEffect other = prop.getEffect();
|
||||
if (other instanceof SpellPortal && other != this && !other.getDead()) {
|
||||
((SpellPortal)other).notifyMatched(this);
|
||||
IMagicEffect other = prop.getEffect();
|
||||
if (other instanceof SpellPortal && other != this && !other.getDead()) {
|
||||
((SpellPortal)other).notifyMatched(this);
|
||||
|
||||
if (!world.isRemote) {
|
||||
prop.setEffect(null);
|
||||
}
|
||||
} else {
|
||||
if (!world.isRemote) {
|
||||
prop.setEffect(this);
|
||||
}
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
prop.setEffect(null);
|
||||
}
|
||||
} else {
|
||||
if (!world.isRemote) {
|
||||
prop.setEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
return SpellCastResult.PLACE;
|
||||
}
|
||||
return SpellCastResult.PLACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity) {
|
||||
return SpellCastResult.NONE;
|
||||
}
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity) {
|
||||
return SpellCastResult.NONE;
|
||||
}
|
||||
|
||||
public void notifyMatched(SpellPortal other) {
|
||||
if (sibling == null) {
|
||||
sibling = other;
|
||||
other.sibling = this;
|
||||
public void notifyMatched(SpellPortal other) {
|
||||
if (sibling == null) {
|
||||
sibling = other;
|
||||
other.sibling = this;
|
||||
|
||||
sibling.destinationPos = position;
|
||||
destinationPos = sibling.position;
|
||||
}
|
||||
}
|
||||
sibling.destinationPos = position;
|
||||
destinationPos = sibling.position;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean updateOnPerson(ICaster<?> caster) {
|
||||
return true;
|
||||
}
|
||||
|
@ -137,26 +137,26 @@ public class SpellPortal extends AbstractSpell implements IUseAction {
|
|||
});
|
||||
}
|
||||
|
||||
public IShape getPortalZone() {
|
||||
switch (axis) {
|
||||
case X: return portalZone_X;
|
||||
default:
|
||||
case Y: return portalZone_Y;
|
||||
case Z: return portalZone_Z;
|
||||
}
|
||||
}
|
||||
public IShape getPortalZone() {
|
||||
switch (axis) {
|
||||
case X: return portalZone_X;
|
||||
default:
|
||||
case Y: return portalZone_Y;
|
||||
case Z: return portalZone_Z;
|
||||
}
|
||||
}
|
||||
|
||||
public AxisAlignedBB getTeleportBounds() {
|
||||
if (axis == EnumFacing.Axis.Y) {
|
||||
return TELEPORT_BOUNDS_VERT;
|
||||
}
|
||||
public AxisAlignedBB getTeleportBounds() {
|
||||
if (axis == EnumFacing.Axis.Y) {
|
||||
return TELEPORT_BOUNDS_VERT;
|
||||
}
|
||||
|
||||
return TELEPORT_BOUNDS;
|
||||
}
|
||||
return TELEPORT_BOUNDS;
|
||||
}
|
||||
|
||||
private boolean teleportNear(ICaster<?> source, int level) {
|
||||
return source.getWorld().getEntitiesWithinAABB(Entity.class, getTeleportBounds().offset(source.getOrigin())).stream().filter(i -> {
|
||||
if (!(i instanceof IMagicals) && i.timeUntilPortal == 0) {
|
||||
private boolean teleportNear(ICaster<?> source, int level) {
|
||||
return source.getWorld().getEntitiesWithinAABB(Entity.class, getTeleportBounds().offset(source.getOrigin())).stream().filter(i -> {
|
||||
if (!(i instanceof IMagicals) && i.timeUntilPortal == 0) {
|
||||
EnumFacing.Axis xi = i.getHorizontalFacing().getAxis();
|
||||
|
||||
if (axis != EnumFacing.Axis.Y && xi != axis) {
|
||||
|
@ -194,58 +194,58 @@ public class SpellPortal extends AbstractSpell implements IUseAction {
|
|||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}).count() > 0;
|
||||
}
|
||||
return false;
|
||||
}).count() > 0;
|
||||
}
|
||||
|
||||
public Optional<SpellPortal> getDestinationPortal(World w) {
|
||||
if (sibling == null && destinationPos != null) {
|
||||
w.getBlockLightOpacity(destinationPos);
|
||||
w.getEntitiesWithinAABB(EntitySpell.class, DESTINATION_BOUNDS.offset(destinationPos)).stream()
|
||||
.filter(i -> i.getEffect() instanceof SpellPortal)
|
||||
.map(i -> (SpellPortal)i.getEffect())
|
||||
.findFirst()
|
||||
.ifPresent(s -> sibling = s);
|
||||
}
|
||||
public Optional<SpellPortal> getDestinationPortal(World w) {
|
||||
if (sibling == null && destinationPos != null) {
|
||||
w.getBlockLightOpacity(destinationPos);
|
||||
w.getEntitiesWithinAABB(EntitySpell.class, DESTINATION_BOUNDS.offset(destinationPos)).stream()
|
||||
.filter(i -> i.getEffect() instanceof SpellPortal)
|
||||
.map(i -> (SpellPortal)i.getEffect())
|
||||
.findFirst()
|
||||
.ifPresent(s -> sibling = s);
|
||||
}
|
||||
|
||||
return Optional.ofNullable(sibling);
|
||||
}
|
||||
return Optional.ofNullable(sibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (destinationPos != null) {
|
||||
NBTTagCompound dest = new NBTTagCompound();
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (destinationPos != null) {
|
||||
NBTTagCompound dest = new NBTTagCompound();
|
||||
|
||||
dest.setInteger("X", destinationPos.getX());
|
||||
dest.setInteger("Y", destinationPos.getY());
|
||||
dest.setInteger("Z", destinationPos.getZ());
|
||||
dest.setInteger("X", destinationPos.getX());
|
||||
dest.setInteger("Y", destinationPos.getY());
|
||||
dest.setInteger("Z", destinationPos.getZ());
|
||||
|
||||
compound.setTag("destination", dest);
|
||||
}
|
||||
compound.setTag("destination", dest);
|
||||
}
|
||||
|
||||
compound.setString("axis", axis.getName2());
|
||||
}
|
||||
compound.setString("axis", axis.getName2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
if (compound.hasKey("destination")) {
|
||||
NBTTagCompound dest = compound.getCompoundTag("destination");
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
if (compound.hasKey("destination")) {
|
||||
NBTTagCompound dest = compound.getCompoundTag("destination");
|
||||
|
||||
destinationPos = new BlockPos(
|
||||
dest.getInteger("X"),
|
||||
dest.getInteger("Y"),
|
||||
dest.getInteger("Z")
|
||||
);
|
||||
}
|
||||
destinationPos = new BlockPos(
|
||||
dest.getInteger("X"),
|
||||
dest.getInteger("Y"),
|
||||
dest.getInteger("Z")
|
||||
);
|
||||
}
|
||||
|
||||
if (compound.hasKey("axis")) {
|
||||
axis = EnumFacing.Axis.byName(compound.getString("axis").toLowerCase(Locale.ROOT));
|
||||
if (compound.hasKey("axis")) {
|
||||
axis = EnumFacing.Axis.byName(compound.getString("axis").toLowerCase(Locale.ROOT));
|
||||
|
||||
if (axis == null) {
|
||||
axis = EnumFacing.Axis.Y;
|
||||
}
|
||||
} else {
|
||||
axis = EnumFacing.Axis.Y;
|
||||
}
|
||||
}
|
||||
if (axis == null) {
|
||||
axis = EnumFacing.Axis.Y;
|
||||
}
|
||||
} else {
|
||||
axis = EnumFacing.Axis.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue