Skip to content

Commit

Permalink
Refactor Entity handling stuff. Start work on making mount across dim…
Browse files Browse the repository at this point in the history
…ensions work.
  • Loading branch information
da3dsoul committed Jul 20, 2015
1 parent e410fa4 commit f5c0265
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
20 changes: 19 additions & 1 deletion src/main/java/me/planetguy/remaininmotion/core/ModRiM.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.planetguy.remaininmotion.core;

import java.io.File;
import java.util.HashMap;
import java.util.UUID;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -24,7 +26,10 @@
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;

@Mod(modid = ModRiM.Handle, name = ModRiM.Title, version = ModRiM.Version, dependencies = "required-after:planetguyLib;after:CoFHCore;after:BuildCraft|Transport")
public class ModRiM {
Expand All @@ -41,7 +46,9 @@ public class ModRiM {
public static PLHelper plHelper;

@Instance(ModRiM.Handle)
public static Object instance;
public static ModRiM instance;

//public HashMap<UUID,Integer> playerMountMap = new HashMap<UUID, Integer>();

@EventHandler
public void PreInit(FMLPreInitializationEvent Event) {
Expand Down Expand Up @@ -130,4 +137,15 @@ public void onJoin(PlayerEvent.PlayerLoggedInEvent event){
if(((EntityPlayerMP) event.player).isClientWorld())
PacketSpecterVelocity.send((EntityPlayerMP) event.player);
}

/*@SubscribeEvent
public void onFinishTeleporting(EntityJoinWorldEvent event){
if(!(event.entity instanceof EntityPlayerMP)) return;
Integer mount = playerMountMap.get(event.entity.getUniqueID());
if(mount != null) {
Entity entity = event.world.getEntityByID(mount);
((EntityPlayerMP)event.entity).mountEntity(entity);
playerMountMap.remove(event.entity.getUniqueID());
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@ public void fixLagError(CapturedEntity capture, Entity entity) {
capture.SetYPosition(motionDirection.deltaY + 0.025);
} else {
if(motionX != 0 || motionZ != 0) {
double[] motion = handleCollision(entity, motionX, motionZ);
double[] motion = handleEntityCollision(entity, motionX, motionZ);
capture.netMotionX += motion[0];
capture.netMotionZ += motion[1];
}
}

}

public void doPerSpectreUpdate(CapturedEntity capture, Entity entity) {
public void doPerSpectreEntityUpdate(CapturedEntity capture, Entity entity) {
entity.fallDistance = 0;

if(motionDirection.deltaX != capture.netMotionX || motionDirection.deltaZ != capture.netMotionZ || motionDirection.deltaY != capture.netMotionY) {
Expand All @@ -490,7 +490,7 @@ public void doPerSpectreUpdate(CapturedEntity capture, Entity entity) {
capture.SetPosition(motionX, 0, motionZ);
capture.SetYPosition(capture.netMotionY);
} else {
double[] motion = handleCollision(entity, motionX, motionZ);
double[] motion = handleEntityCollision(entity, motionX, motionZ);

motionX = motion[0];
motionZ = motion[1];
Expand All @@ -507,7 +507,7 @@ public void doPerSpectreUpdate(CapturedEntity capture, Entity entity) {
}
}

private double[] handleCollision(Entity entity, double motionX, double motionZ) {
private double[] handleEntityCollision(Entity entity, double motionX, double motionZ) {
double X = motionX;
double Z = motionZ;
List list = this.worldObj.getCollidingBoundingBoxes(entity, entity.boundingBox.addCoord(X, 0, Z));
Expand Down Expand Up @@ -752,7 +752,7 @@ public void SetYPosition(double OffsetY) {
}

public void Update() {
doPerSpectreUpdate(this, entity);
doPerSpectreEntityUpdate(this, entity);
}

public void stop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void announceTEConstruction(BlockRecord record) {
}

@Override
public void doPerSpectreUpdate(CapturedEntity capture, Entity entity) {
public void doPerSpectreEntityUpdate(CapturedEntity capture, Entity entity) {
if(capture.startingPosition == null) {
capture.startingPosition=new Matrix(new double[][] { { entity.posX }, { entity.posY }, { entity.posZ } });
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.planetguy.remaininmotion.spectre;

import me.planetguy.remaininmotion.core.ModRiM;
import me.planetguy.remaininmotion.motion.CarriagePackage;
import me.planetguy.remaininmotion.util.position.BlockRecord;
import me.planetguy.remaininmotion.util.position.BlockRecordSet;
Expand Down Expand Up @@ -209,6 +210,7 @@ public Entity TeleportEntity(Entity entity) {
entity.mountEntity(null);

Mount = TeleportEntity(Mount);
//ModRiM.instance.playerMountMap.put(entity.getUniqueID(), Mount.getEntityId());
}

if (entity instanceof EntityPlayerMP) {
Expand Down

0 comments on commit f5c0265

Please sign in to comment.