Add option to related to hologram projection

Also made clear what's public api and what's not.
This commit is contained in:
Glease committed 2021-07-21 17:26:28 +08:00
1 parent c4eb372cfb
commit 68c5436496
19 files changed
+457 -75

No files matched your search

@@ -1,136 +0,0 @@
package com.gtnewhorizon.structurelib.alignment;
import com.gtnewhorizon.structurelib.StructureLib;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
public abstract class AlignmentMessage implements IMessage {
int mPosX;
int mPosY;
int mPosZ;
int mPosD;
int mAlign;
public AlignmentMessage() {
}
@Override
public void fromBytes(ByteBuf pBuffer) {
NBTTagCompound tTag = ByteBufUtils.readTag(pBuffer);
mPosX = tTag.getInteger("posx");
mPosY = tTag.getInteger("posy");
mPosZ = tTag.getInteger("posz");
mPosD = tTag.getInteger("posd");
mAlign = tTag.getInteger("rotf");
}
@Override
public void toBytes(ByteBuf pBuffer) {
NBTTagCompound tFXTag = new NBTTagCompound();
tFXTag.setInteger("posx", mPosX);
tFXTag.setInteger("posy", mPosY);
tFXTag.setInteger("posz", mPosZ);
tFXTag.setInteger("posd", mPosD);
tFXTag.setInteger("rotf", mAlign);
ByteBufUtils.writeTag(pBuffer, tFXTag);
}
private AlignmentMessage(IAlignmentProvider provider) {
if (!(provider instanceof TileEntity))
throw new IllegalArgumentException("Provider must be a TileEntity");
IAlignment alignment = provider.getAlignment();
if (alignment == null)
throw new IllegalArgumentException("Passed in provider does not provide an alignment!");
TileEntity base = (TileEntity) provider;
mPosX = base.xCoord;
mPosY = base.yCoord;
mPosZ = base.zCoord;
mPosD = base.getWorldObj().provider.dimensionId;
mAlign = alignment.getExtendedFacing().getIndex();
}
private AlignmentMessage(World world, int x, int y, int z, IAlignment front) {
mPosX = x;
mPosY = y;
mPosZ = z;
mPosD = world.provider.dimensionId;
mAlign = front.getExtendedFacing().getIndex();
}
public static class AlignmentQuery extends AlignmentMessage {
public AlignmentQuery() {
}
public AlignmentQuery(IAlignmentProvider provider) {
super(provider);
}
public AlignmentQuery(World world, int x, int y, int z, IAlignment front) {
super(world, x, y, z, front);
}
}
public static class AlignmentData extends AlignmentMessage {
public AlignmentData() {
}
private AlignmentData(AlignmentQuery query) {
mPosX = query.mPosX;
mPosY = query.mPosY;
mPosZ = query.mPosZ;
mPosD = query.mPosD;
mAlign = query.mAlign;
}
public AlignmentData(IAlignmentProvider provider) {
super(provider);
}
public AlignmentData(World world, int x, int y, int z, IAlignment front) {
super(world, x, y, z, front);
}
}
public static class ClientHandler implements IMessageHandler<AlignmentData, IMessage> {
@Override
public IMessage onMessage(AlignmentData pMessage, MessageContext pCtx) {
if (StructureLib.getCurrentPlayer().worldObj.provider.dimensionId == pMessage.mPosD) {
TileEntity te = StructureLib.getCurrentPlayer().worldObj.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ);
if (te instanceof IAlignmentProvider) {
IAlignment alignment = ((IAlignmentProvider) te).getAlignment();
if (alignment != null) {
alignment.setExtendedFacing(ExtendedFacing.byIndex(pMessage.mAlign));
}
}
}
return null;
}
}
public static class ServerHandler implements IMessageHandler<AlignmentQuery, AlignmentData> {
@Override
public AlignmentData onMessage(AlignmentQuery pMessage, MessageContext pCtx) {
World world = DimensionManager.getWorld(pMessage.mPosD);
if (world != null) {
TileEntity te = world.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ);
if (te instanceof IAlignmentProvider) {
IAlignment alignment = ((IAlignmentProvider) te).getAlignment();
if (alignment == null)
return null;
pMessage.mAlign = alignment.getExtendedFacing().getIndex();
return new AlignmentData(pMessage);
}
}
return null;
}
}
}
@@ -1,6 +1,7 @@
package com.gtnewhorizon.structurelib.alignment.constructable;
import com.gtnewhorizon.structurelib.StructureLib;
import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.alignment.IAlignment;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import net.minecraft.entity.player.EntityPlayer;
@@ -17,6 +18,13 @@ public class ConstructableUtility {
}
public static boolean handle(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide) {
StructureLibAPI.startHinting(aWorld);
boolean ret = handle0(aStack, aPlayer, aWorld, aX, aY, aZ, aSide);
StructureLibAPI.endHinting(aWorld);
return ret;
}
private static boolean handle0(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
return aPlayer instanceof EntityPlayerMP;
@@ -14,6 +14,10 @@ import java.util.HashMap;
public interface IMultiblockInfoContainer<T> {
HashMap<String, IMultiblockInfoContainer<?>> MULTIBLOCK_MAP = new HashMap<>();
/**
* There is no specific loading phase restriction, but you should generally not call it before the tile entity is
* properly registered.
*/
static <T extends TileEntity> void registerTileClass(Class<T> clazz, IMultiblockInfoContainer<?> info) {
MULTIBLOCK_MAP.put(clazz.getCanonicalName(), info);
}
@@ -0,0 +1,5 @@
/**
* All public stuff in this package and its subpackages are considered part of the public API.
* Backwards compatibility is maintained to the maximum extend possible.
*/
package com.gtnewhorizon.structurelib.alignment;