Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.fluffy2.amnesialights.handler;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.util.MovingObjectPosition;
- import net.minecraft.util.MovingObjectPosition.MovingObjectType;
- import net.minecraft.util.Vec3;
- import net.minecraft.world.World;
- import net.minecraft.world.WorldServer;
- import net.minecraftforge.common.IExtendedEntityProperties;
- import com.fluffy2.amnesialights.AmnesiaLights;
- import com.fluffy2.amnesialights.pakets.HotbarLanternMessageHandler;
- public class ExtendedPlayerPropertiesHandler implements IExtendedEntityProperties{
- public final static String PropName = AmnesiaLights.ModID+"_Player_Properties";
- private int lastPlayerX;
- private int lastPlayerY;
- private int lastPlayerZ;
- private int rayTraceX;
- private int rayTraceY;
- private int rayTraceZ;
- private int lastPlayerX2;
- private int lastPlayerY2;
- private int lastPlayerZ2;
- private boolean lanternEquipped;
- private boolean candleEquipped;
- private boolean flashlightEquipped;
- private boolean bullseyeEquipped;
- private boolean quickEquipped;
- private boolean quick2Equipped;
- public int hotbarLantern;
- private final EntityPlayer player;
- public ExtendedPlayerPropertiesHandler(EntityPlayer player){
- this.player = player;
- this.lastPlayerX = 0;
- this.lastPlayerY = 0;
- this.lastPlayerZ = 0;
- this.rayTraceX = 0;
- this.rayTraceY = 0;
- this.rayTraceZ = 0;
- this.lastPlayerX2 = 0;
- this.lastPlayerY2 = 0;
- this.lastPlayerZ2 = 0;
- this.lanternEquipped = false;
- this.bullseyeEquipped = false;
- this.candleEquipped = false;
- this.flashlightEquipped = false;
- this.quickEquipped = false;
- this.quick2Equipped = false;
- this.hotbarLantern = 0;
- }
- public static final void register(EntityPlayer player){
- player.registerExtendedProperties(ExtendedPlayerPropertiesHandler.PropName, new ExtendedPlayerPropertiesHandler(player));
- }
- public static final ExtendedPlayerPropertiesHandler get(EntityPlayer player){
- return (ExtendedPlayerPropertiesHandler)player.getExtendedProperties(PropName);
- }
- @Override
- public void saveNBTData(NBTTagCompound compound){
- }
- @Override
- public void loadNBTData(NBTTagCompound compound){
- }
- @Override
- public void init(Entity entity, World world){
- }
- //getCurrentPos
- public int getPlayerPosX(){
- return (int)Math.floor(this.player.posX);
- }
- public int getPlayerPosY(){
- return (int)Math.floor(this.player.posY);
- }
- public int getPlayerPosZ(){
- return (int)Math.floor(this.player.posZ);
- }
- //getLastPos
- public int getLastPosX(){
- return this.lastPlayerX;
- }
- public int getLastPosY(){
- return this.lastPlayerY;
- }
- public int getLastPosZ(){
- return this.lastPlayerZ;
- }
- //getRayTrace
- public int getRayTraceX(){
- return this.rayTraceX;
- }
- public int getRayTraceY(){
- return this.rayTraceY;
- }
- public int getRayTraceZ(){
- return this.rayTraceZ;
- }
- //getLashPos2
- public int getLastPosX2(){
- return this.lastPlayerX2;
- }
- public int getLastPosY2(){
- return this.lastPlayerY2;
- }
- public int getLastPosZ2(){
- return this.lastPlayerZ2;
- }
- //getBoolean
- public boolean isLanternEquipped(){
- return this.lanternEquipped;
- }
- public boolean isBullseyeEquipped(){
- return this.bullseyeEquipped;
- }
- public boolean isCandleEquipped(){
- return this.candleEquipped;
- }
- public boolean isFlashlightEquipped(){
- return this.flashlightEquipped;
- }
- public boolean isQuickEquipped(){
- return this.quickEquipped;
- }
- public boolean isQuick2Equipped(){
- return this.quick2Equipped;
- }
- //setLastPos
- public void setLastPos(int x, int y, int z){
- this.lastPlayerX = x;
- this.lastPlayerY = y;
- this.lastPlayerZ = z;
- }
- //setRayTrace
- public void setRayTrace(double distance){
- Vec3 look = player.getLookVec();
- Vec3 pos = new Vec3(player.posX, player.posY+player.getEyeHeight(), player.posZ);
- Vec3 addedlook = pos.addVector(look.xCoord * distance, look.yCoord * distance, look.zCoord * distance);
- MovingObjectPosition mop = player.worldObj.rayTraceBlocks(pos, addedlook);
- if(mop != null && mop.typeOfHit == MovingObjectType.BLOCK){
- this.rayTraceX = mop.getBlockPos().getX();
- this.rayTraceY = mop.getBlockPos().getY();
- this.rayTraceZ = mop.getBlockPos().getZ();
- }else{
- this.rayTraceX = (int)Math.floor(addedlook.xCoord);
- this.rayTraceY = (int)Math.floor(addedlook.yCoord);
- this.rayTraceZ = (int)Math.floor(addedlook.zCoord);
- }
- }
- //setLastPos2
- public void setLastPos2(int x, int y, int z){
- this.lastPlayerX2 = x;
- this.lastPlayerY2 = y;
- this.lastPlayerZ2 = z;
- }
- //setBoolean
- public void setLanternEquipped(boolean state){
- this.lanternEquipped = state;
- }
- public void setBullseyeEquipped(boolean state){
- this.bullseyeEquipped = state;
- }
- public void setCandleEquipped(boolean state){
- this.candleEquipped = state;
- }
- public void setFlashlightEquipped(boolean state){
- this.flashlightEquipped = state;
- }
- public void setQuickEquipped(boolean state){
- this.quickEquipped = state;
- }
- public void setQuick2Equipped(boolean state){
- this.quick2Equipped = state;
- }
- //hotbarLantern
- public int hotbarLantern(){
- return this.hotbarLantern;
- }
- public void setHotbarLantern(int state){
- this.hotbarLantern = state;
- ((WorldServer)player.worldObj).getEntityTracker().func_151248_b(player, AmnesiaLights.snw.getPacketFrom(new HotbarLanternMessageHandler(player, state)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment