Swap the API packages

The new one is now built for the api jar and the old one is now internal.
It will slowly be moved around to sane places within the internal code. Most
of the features provided in the old "api" are addon specific features which
will generally rely on the main jar anyways. The new API will be specific
to compatibility features, such as blacklists, recipes, and value modification.
This commit is contained in:
Nicholas Ignoffo 2018-02-05 17:04:38 -08:00
parent 4fbcac6aa2
commit ddaadfbe52
421 changed files with 1006 additions and 999 deletions

View file

@ -0,0 +1,7 @@
package WayofTime.bloodmagic.apibutnotreally.teleport;
public interface ITeleport {
void teleport();
int getTeleportCost();
}

View file

@ -0,0 +1,90 @@
package WayofTime.bloodmagic.apibutnotreally.teleport;
import WayofTime.bloodmagic.apibutnotreally.Constants;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import java.io.Serializable;
public class PortalLocation implements Serializable {
private int x;
private int y;
private int z;
private int dimension;
public PortalLocation(int x, int y, int z, int dimension) {
this.x = x;
this.y = y;
this.z = z;
this.dimension = dimension;
}
public PortalLocation(BlockPos blockPos, int dimension) {
this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), dimension);
}
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
NBTTagCompound locationTag = new NBTTagCompound();
locationTag.setInteger(Constants.NBT.X_COORD, x);
locationTag.setInteger(Constants.NBT.Y_COORD, y);
locationTag.setInteger(Constants.NBT.Z_COORD, z);
locationTag.setInteger(Constants.NBT.DIMENSION_ID, dimension);
tag.setTag(Constants.NBT.PORTAL_LOCATION, locationTag);
return tag;
}
public BlockPos getBlockPos() {
return new BlockPos(x, y, z);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
PortalLocation that = (PortalLocation) o;
if (x != that.x)
return false;
if (y != that.y)
return false;
return z == that.z;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
public int getDimension() {
return dimension;
}
public static PortalLocation readFromNBT(NBTTagCompound tag) {
if (tag.hasKey(Constants.NBT.PORTAL_LOCATION)) {
NBTTagCompound locationTag = tag.getCompoundTag(Constants.NBT.PORTAL_LOCATION);
return new PortalLocation(locationTag.getInteger(Constants.NBT.X_COORD), locationTag.getInteger(Constants.NBT.Y_COORD), locationTag.getInteger(Constants.NBT.Z_COORD), locationTag.getInteger(Constants.NBT.DIMENSION_ID));
}
return null;
}
}

View file

@ -0,0 +1,68 @@
package WayofTime.bloodmagic.apibutnotreally.teleport;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
public abstract class Teleport implements ITeleport {
protected int x;
protected int y;
protected int z;
protected Entity entity;
protected String networkToDrain;
public Teleport(int x, int y, int z, Entity entity, String networkToDrain) {
this.x = x;
this.y = y;
this.z = z;
this.entity = entity;
this.networkToDrain = networkToDrain;
}
public Teleport(BlockPos blockPos, Entity entity, String networkToDrain) {
this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), entity, networkToDrain);
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
public Entity getEntity() {
return entity;
}
public String getNetworkToDrain() {
return networkToDrain;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Teleport)) return false;
Teleport teleport = (Teleport) o;
if (x != teleport.x) return false;
if (y != teleport.y) return false;
if (z != teleport.z) return false;
if (entity != null ? !entity.equals(teleport.entity) : teleport.entity != null) return false;
return networkToDrain != null ? networkToDrain.equals(teleport.networkToDrain) : teleport.networkToDrain == null;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
result = 31 * result + (entity != null ? entity.hashCode() : 0);
result = 31 * result + (networkToDrain != null ? networkToDrain.hashCode() : 0);
return result;
}
}

View file

@ -0,0 +1,37 @@
package WayofTime.bloodmagic.apibutnotreally.teleport;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.ArrayList;
import java.util.List;
public class TeleportQueue {
private static TeleportQueue INSTANCE = new TeleportQueue();
private static List<ITeleport> queue;
private TeleportQueue() {
queue = new ArrayList<ITeleport>();
}
public void addITeleport(ITeleport iTeleport) {
queue.add(iTeleport);
}
@SubscribeEvent
public void serverTick(TickEvent.ServerTickEvent event) {
if (event.phase != TickEvent.Phase.END) {
return;
}
for (ITeleport iTeleport : queue) {
iTeleport.teleport();
}
queue.clear();
}
public static TeleportQueue getInstance() {
return INSTANCE;
}
}

View file

@ -0,0 +1,32 @@
package WayofTime.bloodmagic.apibutnotreally.teleport;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;
public class TeleporterBloodMagic extends Teleporter {
public TeleporterBloodMagic(WorldServer worldServer) {
super(worldServer);
}
@Override
public boolean makePortal(Entity entity) {
return true;
}
@Override
public void removeStalePortalLocations(long worldTime) {
;
}
@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) {
return true;
}
@Override
public void placeInPortal(Entity entity, float rotationYaw) {
entity.setLocationAndAngles(MathHelper.floor(entity.posX), MathHelper.floor(entity.posY) + 2, MathHelper.floor(entity.posZ), entity.rotationYaw, entity.rotationPitch);
}
}