Updated to apply custom structure Positions to AngleGetter() class
This commit is contained in:
@@ -10,6 +10,7 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.yseven.findyourway.item.ItemCompassBase;
|
||||
import net.yseven.findyourway.item.ModItems;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -23,9 +24,13 @@ public class AngleGetter implements IItemPropertyGetter {
|
||||
private double prevWobble = 0.0D;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private long prevWorldTime = 0L;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private BlockPos blockPos;
|
||||
|
||||
double blockX;
|
||||
double blockZ;
|
||||
@SideOnly(Side.CLIENT)
|
||||
AngleGetter(ItemCompassBase compassBase) {
|
||||
blockPos = compassBase.getStructurePos();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
@@ -66,16 +71,11 @@ public class AngleGetter implements IItemPropertyGetter {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private double getAngle(World world, Entity entity, ItemStack stack) {
|
||||
return Math.atan2((double) blockZ - entity.posZ, (double) blockX - entity.posX);
|
||||
return Math.atan2((double) blockPos.getZ() - entity.posZ, (double) blockPos.getX() - entity.posX);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private double getFrameAngle(EntityItemFrame entity) {
|
||||
return (double) MathHelper.wrapDegrees(180 + (entity.facingDirection.getHorizontalIndex() * 90));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private double getPosToAngle(BlockPos pos, Entity entity) {
|
||||
return Math.atan2((double)pos.getZ() - entity.posZ, (double)pos.getX() - entity.posX);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.yseven.findyourway.CommonProxy;
|
||||
import net.yseven.findyourway.FindYourWay;
|
||||
import net.yseven.findyourway.Network.PacketHandler;
|
||||
@@ -82,9 +83,10 @@ public class ClientProxy extends CommonProxy {
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(FindYourWay.modId + ":" + id, "inventory"));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onModelRegistry(ModelRegistryEvent event) {
|
||||
ModItems.ENDER_COMPASS.addPropertyOverride(new ResourceLocation(ModItems.ENDER_COMPASS.assetTag), new AngleGetter());
|
||||
ModItems.ENDER_COMPASS.addPropertyOverride(new ResourceLocation(ModItems.ENDER_COMPASS.assetTag), new AngleGetter(ModItems.ENDER_COMPASS));
|
||||
ModelLoader.setCustomModelResourceLocation(ModItems.ENDER_COMPASS, 0, new ModelResourceLocation("findyourway:ender_compass", "inventory"));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user