Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I started porting FreezeCam for myself from forge 1.7.10 to forge 1.12.2 and ran into a problem I can't control my player when creating a camera as done in this mod when creating a player entity with this code

   public void CreateEntity(EnumFunction function, boolean isSneaking, String Name) {
      if (getMC().player != null && getMC().world != null) {
         CamEntity Ent;
         if (function == EnumFunction.FreezeCam) {
            Ent = this.CamEnt = new CamEntity(getMC().world, Name, isSneaking, function);
         } else {
            Ent = this.Statue = new CamEntity(getMC().world, Name, isSneaking, function);
         }

         Ent.setPosition(getMC().player.posX, getMC().player.posY, getMC().player.posZ);
         getMC().world.spawnEntity(Ent);
         Ent.rotationPitch = getMC().player.rotationPitch;
         Ent.rotationYaw = getMC().player.rotationYaw;
         Ent.rotationYawHead = getMC().player.rotationYawHead;
         if (function == EnumFunction.FreezeCam) {
            getMC().setRenderViewEntity(Ent);
         }
      }
   }

   public void CreateEntity(EnumFunction function, String Name) {
      if (getMC().player != null && getMC().world != null) {
         CamEntity Ent;
         if (function == EnumFunction.FreezeCam) {
            Ent = this.CamEnt = new CamEntity(getMC().world, Name, function);
         } else {
            Ent = this.Statue = new CamEntity(getMC().world, Name, function);
         }

         Ent.setPosition(getMC().player.posX, getMC().player.posY, getMC().player.posZ);
         getMC().world.spawnEntity(Ent);
         Ent.rotationPitch = getMC().player.rotationPitch;
         Ent.rotationYaw = getMC().player.rotationYaw;
         Ent.rotationYawHead = getMC().player.rotationYawHead;
         if (function == EnumFunction.FreezeCam) {
            getMC().setRenderViewEntity(this.CamEnt);
         }
      }
   }


here's the CamEntity class:

package com.DSG.mc.FreezeCam;

import com.DSG.mc.FreezeCam.Utils.DSGUtils;
import com.mojang.authlib.GameProfile;

import java.util.UUID;

import net.minecraft.client.entity.EntityOtherPlayerMP;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;

public class CamEntity extends EntityOtherPlayerMP {
   private EntityLivingBase follow;
   private int LookDistance;
   public EnumFunction MyFunction;
   private boolean isSneaking;

   public CamEntity(World MCworld, String iName, EnumFunction function) {
      this(MCworld, iName, false, function);
   }

   public CamEntity(World MCworld, String iName, boolean isSneaking, EnumFunction function) {
      super(MCworld, new GameProfile(UUID.fromString("8667ba71-b85a-4004-af54-457a9734eed7"), iName));
      this.follow = null;
      this.LookDistance = 10;
      super.capabilities.isFlying = true;
      this.MyFunction = function;
      this.isSneaking = isSneaking;
      super.noClip = true;
   }

   public void onLivingUpdate() {
      if (this.MyFunction == EnumFunction.FreezeCam && DSGUtils.getInstance().followPlayer) {
         try {
            this.follow = DSGUtils.getMC().player;
            DSGUtils.getMC().player.setSprinting(this.follow.isSprinting());
            DSGUtils.getInstance().faceEntity(this, this.follow, 100.0F, 100.0F);
            double high = DSGUtils.getMC().player.posY - super.posY;
            if (DSGUtils.getMC().player.getDistance(this) >= (float)DSGUtils.getInstance().ParseDistance()) {
               super.moveForward = (float)((double)DSGUtils.getMC().player.capabilities.getWalkSpeed() * (DSGUtils.getMC().player.capabilities.isFlying ? 10.0D : 2.0D) / 4.2D);
               if (high >= 2.0D) {
                  super.motionY = 0.2D;
               }
               if (high <= -2.0D) {
                  super.motionY = -0.2D;
               }
            } else {
               super.motionX = 0.0D;
               super.motionZ = 0.0D;
            }
         } catch (Exception var5) {
            System.out.println("Follow player has been disabled");
            DSGUtils.AddChat("Follow player has been disabled");
            DSGUtils.getInstance().followPlayer = false;
         }
      }
      if (this.MyFunction == EnumFunction.Look && !this.isSleeping()) {
         try {
            if (DSGUtils.getMC().player.getDistance(this) <= (float)this.LookDistance) {
               DSGUtils.getInstance().faceEntity(this, DSGUtils.getMC().player, 160.0F, 160.0F);
            }
         } catch (Exception var4) {
            System.out.println("IM CRASHED WITH FACING A PLAYER !!!");
            DSGUtils.AddChat("One of your statues is despawned!");
            super.dead = true;
         }
      }
      if (this.MyFunction == EnumFunction.Statue) {
         super.cameraPitch = super.rotationPitch;
      }
      super.onLivingUpdate();
   }

   public void Interacted() {
      if (this.MyFunction == EnumFunction.Look || this.MyFunction == EnumFunction.Statue) {
         this.setDead();
      }

   }

   public boolean isSneaking() {
      return this.isSneaking;
   }

   public void setSneaking(boolean flag) {
      this.isSneaking = flag;
   }

   public EnumFunction myFunction() {
      return this.MyFunction;
   }

   public CamEntity cloneMe() {
      return this;
   }

   public boolean isSleeping() {
      return super.sleeping;
   }

   public void setSleeping(boolean flag) {
      super.sleeping = flag;
   }

   public void setLookDistance(int newValue) {
      this.LookDistance = newValue;
   }

   public int getLookDistance() {
      return this.LookDistance;
   }

   public String getUsername() {
      return this.getDisplayName().getFormattedText();
   }

   protected boolean isMovementBlocked() {
      return false;
   }
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.