Jump to content

Recommended Posts

Posted

Why doesn't this work? 

I have vec3 set as a Vec3d and isVecInside is defined for axisalignedbb

 

Relvant Code

 

 
 
 
 
Spoiler

Vec3d vec3 = Minecraft.getMinecraft().getRenderViewEntity().getPositionEyes(partialTicks);
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expand((double)f2, (double)f2, (double)f2);
Entity entity = (Entity)list.get(i);
if (axisalignedbb.isVecInside(vec3)) { //This is where i get the error

 

 

 

Full Code

 

 
 
 
 
Spoiler

import java.util.List;
import java.lang.Object;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;

@Mod(
   modid = "HitBox Mod",
   version = "0.0.2",
   acceptedMinecraftVersions = "[1.12.2]"
)
public class HitBoxMod {
   public static final String MODID = "HitBox Mod";
   public static final String VERSION = "0.0.2";
   protected Minecraft mc = Minecraft.getMinecraft();
   private Entity pointedEntity;
   private RayTraceResult moving;
   public static float hitBoxMultiplier = 1.0F;

   @EventHandler
   public void init(FMLInitializationEvent event) {
      MinecraftForge.EVENT_BUS.register(this);
      ClientCommandHandler.instance.registerCommand(new HitBoxCommands());
   }

   @SubscribeEvent
   public void onMouse(MouseEvent e) {
      try {
         if (this.moving != null && e.getButton() == 0 && e.isButtonstate()) {
            this.mc.objectMouseOver = this.moving;
         }
      } catch (Exception var3) {
         var3.printStackTrace();
      }

   }

   @SubscribeEvent
   public void onTick(ClientTickEvent e) {
      HitBoxCommands getHitBoxValue = new HitBoxCommands();
      if (this.mc.world != null) {
         hitBoxMultiplier = HitBoxCommands.expandMultiplier;
      }

      this.getMouseOver(1.0F);
   }
   
   @EventHandler
   private void getMouseOver(float partialTicks) {
      if (Minecraft.getMinecraft().getRenderViewEntity() != null && Minecraft.getMinecraft().world != null) {
         Minecraft.getMinecraft().pointedEntity = null;
         double d0 = 3.0D;
         this.moving = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(d0, partialTicks);
         double d1 = d0;
         Vec3d vec3 = Minecraft.getMinecraft().getRenderViewEntity().getPositionEyes(partialTicks);
         if (this.moving != null) {
            d1 = this.moving.hitVec.distanceTo(vec3);
         }

         Vec3d vec31 = Minecraft.getMinecraft().getRenderViewEntity().getLook(partialTicks);
         Vec3d vec32 = vec3.addVector(vec31.x * d0, vec31.y * d0, vec31.z * d0);
         this.pointedEntity = null;
         Vec3d vec33 = null;
         float f1 = 1.0F;
         List<Entity> list = Minecraft.getMinecraft().world.getEntitiesWithinAABBExcludingEntity(Minecraft.getMinecraft().getRenderViewEntity(), ((Object) Minecraft.getMinecraft().getRenderViewEntity().getEntityBoundingBox()).addCoord(vec31.x * d0, vec31.y * d0, vec31.z * d0).expand((double)f1, (double)f1, (double)f1));
         double d2 = d1;

         
         for(int i = 0; i < list.size(); ++i) {
            Entity entity = (Entity)list.get(i);
            if (entity.canBeCollidedWith()) {
               float f2 = 0.13F * hitBoxMultiplier;
               AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expand((double)f2, (double)f2, (double)f2);
               RayTraceResult movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
               if (axisalignedbb.isVecInside(vec3)) {
                  if (0.0D < d2 || d2 == 0.0D) {
                     this.pointedEntity = entity;
                     vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec;
                     d2 = 0.0D;
                  }
               } else if (movingobjectposition != null) {
                  double d3 = vec3.distanceTo(movingobjectposition.hitVec);
                  if (d3 < d2 || d2 == 0.0D) {
                     if (entity == Minecraft.getMinecraft().getRenderViewEntity().getRidingEntity() && !entity.canRiderInteract()) {
                        if (d2 == 0.0D) {
                           this.pointedEntity = entity;
                           vec33 = movingobjectposition.hitVec;
                        }
                     } else {
                        this.pointedEntity = entity;
                        vec33 = movingobjectposition.hitVec;
                        d2 = d3;
                     }
                  }
               }
            }
         }

         if (this.pointedEntity != null && (d2 < d1 || this.moving == null)) {
            this.moving = new RayTraceResult(this.pointedEntity, vec33);
            if (this.pointedEntity instanceof EntityLivingBase || this.pointedEntity instanceof EntityItemFrame) {
               Minecraft.getMinecraft().pointedEntity = this.pointedEntity;
            }
         }
      }

   }
}

 

 

Posted

What's the error?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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