Skip to content

Commit

Permalink
Infernal Mobs getting code to compile again
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicStryker committed Dec 11, 2016
1 parent bf78eb2 commit 9a3e890
Show file tree
Hide file tree
Showing 21 changed files with 315 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public class InfernalMobsClient implements ISidedProxy
private long nextPacketTime;
private ConcurrentHashMap<EntityLivingBase, MobModifier> rareMobsClient;
private int airOverrideValue = -999;

private long healthBarRetainTime;
private EntityLivingBase retainedTarget;

@Override
public void preInit()
{
Expand All @@ -56,46 +56,47 @@ public void load()
{
nextPacketTime = 0;
rareMobsClient = new ConcurrentHashMap<>();

MinecraftForge.EVENT_BUS.register(new RendererBossGlow());
MinecraftForge.EVENT_BUS.register(this);

healthBarRetainTime = 0;
retainedTarget = null;
}

@SubscribeEvent
public void onEntityJoinedWorld(EntityJoinWorldEvent event)
{
if (event.getWorld().isRemote && mc.thePlayer != null
&& (event.getEntity() instanceof EntityMob || (event.getEntity() instanceof EntityLivingBase && event.getEntity() instanceof IMob)))
if (event.getWorld().isRemote && mc.player != null && (event.getEntity() instanceof EntityMob || (event.getEntity() instanceof EntityLivingBase && event.getEntity() instanceof IMob)))
{
InfernalMobsCore.instance().networkHelper.sendPacketToServer(new MobModsPacket(mc.thePlayer.getName(), event.getEntity()
.getEntityId(), (byte) 0));
InfernalMobsCore.instance().networkHelper.sendPacketToServer(new MobModsPacket(mc.player.getName(), event.getEntity().getEntityId(), (byte) 0));
}
}

private void askServerHealth(Entity ent)
{
if (System.currentTimeMillis() > nextPacketTime)
{
InfernalMobsCore.instance().networkHelper.sendPacketToServer(new HealthPacket(mc.thePlayer.getName(), ent.getEntityId(), 0f, 0f));
InfernalMobsCore.instance().networkHelper.sendPacketToServer(new HealthPacket(mc.player.getName(), ent.getEntityId(), 0f, 0f));
nextPacketTime = System.currentTimeMillis() + 100L;
}
}

@SubscribeEvent
public void onPreRenderGameOverlay(RenderGameOverlayEvent.Pre event)
{
if (InfernalMobsCore.instance().getIsHealthBarDisabled() ||
event.getType() != RenderGameOverlayEvent.ElementType.BOSSHEALTH || mc.ingameGUI.getBossOverlay().shouldPlayEndBossMusic()) // TODO probably needs more logic
if (InfernalMobsCore.instance().getIsHealthBarDisabled() || event.getType() != RenderGameOverlayEvent.ElementType.BOSSHEALTH || mc.ingameGUI.getBossOverlay().shouldPlayEndBossMusic()) // TODO
// probably
// needs
// more
// logic
{
return;
}

Entity ent = getEntityCrosshairOver(event.getPartialTicks(), mc);
boolean retained = false;

if (ent == null && System.currentTimeMillis() < healthBarRetainTime)
{
ent = retainedTarget;
Expand Down Expand Up @@ -148,13 +149,13 @@ public void onPreRenderGameOverlay(RenderGameOverlayEvent.Pre event)

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Gui.ICONS);

if (!retained)
{
retainedTarget = target;
healthBarRetainTime = System.currentTimeMillis() + 3000L;
}

}
}
}
Expand All @@ -165,7 +166,7 @@ private Entity getEntityCrosshairOver(float renderTick, Minecraft mc)

if (mc.getRenderViewEntity() != null)
{
if (mc.theWorld != null)
if (mc.world != null)
{
double reachDistance = NAME_VISION_DISTANCE;
final RayTraceResult mopos = mc.getRenderViewEntity().rayTrace(reachDistance, renderTick);
Expand All @@ -178,18 +179,16 @@ private Entity getEntityCrosshairOver(float renderTick, Minecraft mc)
}

final Vec3d viewEntityLookVec = mc.getRenderViewEntity().getLook(renderTick);
final Vec3d actualReachVector =
viewEntPositionVec.addVector(viewEntityLookVec.xCoord * reachDistance, viewEntityLookVec.yCoord * reachDistance,
viewEntityLookVec.zCoord * reachDistance);
final Vec3d actualReachVector = viewEntPositionVec.addVector(viewEntityLookVec.xCoord * reachDistance, viewEntityLookVec.yCoord * reachDistance,
viewEntityLookVec.zCoord * reachDistance);
float expandBBvalue = 1.0F;
double lowestDistance = reachDist2;
Entity iterEnt;
Entity pointedEntity = null;
for (Object obj : mc.theWorld.getEntitiesWithinAABBExcludingEntity(
mc.getRenderViewEntity(),
mc.getRenderViewEntity().getEntityBoundingBox().addCoord(viewEntityLookVec.xCoord * reachDistance, viewEntityLookVec.yCoord * reachDistance,
viewEntityLookVec.zCoord * reachDistance).expand((double) expandBBvalue, (double) expandBBvalue,
(double) expandBBvalue)))
for (Object obj : mc.world.getEntitiesWithinAABBExcludingEntity(mc.getRenderViewEntity(),
mc.getRenderViewEntity().getEntityBoundingBox()
.addCoord(viewEntityLookVec.xCoord * reachDistance, viewEntityLookVec.yCoord * reachDistance, viewEntityLookVec.zCoord * reachDistance)
.expand((double) expandBBvalue, (double) expandBBvalue, (double) expandBBvalue)))
{
iterEnt = (Entity) obj;
if (iterEnt.canBeCollidedWith())
Expand Down Expand Up @@ -228,18 +227,18 @@ else if (interceptObjectPosition != null)

return returnedEntity;
}

@SubscribeEvent
public void onTick(TickEvent.RenderTickEvent tick)
{
if (mc.theWorld == null || (mc.currentScreen != null && mc.currentScreen.doesGuiPauseGame()))
if (mc.world == null || (mc.currentScreen != null && mc.currentScreen.doesGuiPauseGame()))
return;

/* client reset in case of swapping worlds */
if (mc.theWorld != lastWorld)
if (mc.world != lastWorld)
{
boolean newGame = lastWorld == null;
lastWorld = mc.theWorld;
lastWorld = mc.world;

if (!newGame)
{
Expand All @@ -257,13 +256,14 @@ public ConcurrentHashMap<EntityLivingBase, MobModifier> getRareMobs()
@Override
public void onHealthPacketForClient(int entID, float health, float maxhealth)
{
Entity ent = FMLClientHandler.instance().getClient().theWorld.getEntityByID(entID);
Entity ent = FMLClientHandler.instance().getClient().world.getEntityByID(entID);
if (ent != null && ent instanceof EntityLivingBase)
{
MobModifier mod = InfernalMobsCore.getMobModifiers((EntityLivingBase) ent);
if (mod != null)
{
//System.out.printf("health packet [%f of %f] for %s\n", health, maxhealth, ent);
// System.out.printf("health packet [%f of %f] for %s\n",
// health, maxhealth, ent);
mod.setActualHealth(health, maxhealth);
}
}
Expand All @@ -272,43 +272,43 @@ public void onHealthPacketForClient(int entID, float health, float maxhealth)
@Override
public void onKnockBackPacket(float xv, float zv)
{
MM_Gravity.knockBack(FMLClientHandler.instance().getClient().thePlayer, xv, zv);
MM_Gravity.knockBack(FMLClientHandler.instance().getClient().player, xv, zv);
}

@Override
public void onMobModsPacketToClient(String stringData, int entID)
{
InfernalMobsCore.instance().addRemoteEntityModifiers(FMLClientHandler.instance().getClient().theWorld, entID, stringData);
InfernalMobsCore.instance().addRemoteEntityModifiers(FMLClientHandler.instance().getClient().world, entID, stringData);
}

@Override
public void onVelocityPacket(float xv, float yv, float zv)
{
FMLClientHandler.instance().getClient().thePlayer.addVelocity(xv, yv, zv);
FMLClientHandler.instance().getClient().player.addVelocity(xv, yv, zv);
}

@Override
public void onAirPacket(int air)
{
airOverrideValue = air;
}

@SubscribeEvent
public void onTick(RenderGameOverlayEvent.Pre event)
{
if (event.getType() == RenderGameOverlayEvent.ElementType.AIR)
{
if (!mc.thePlayer.isInsideOfMaterial(Material.WATER) && airOverrideValue != -999)
if (!mc.player.isInsideOfMaterial(Material.WATER) && airOverrideValue != -999)
{
final ScaledResolution res = new ScaledResolution(mc);
GL11.glEnable(GL11.GL_BLEND);

int right_height = 39;

final int left = res.getScaledWidth() / 2 + 91;
final int top = res.getScaledHeight() - right_height;
final int full = MathHelper.ceiling_double_int((double)(airOverrideValue - 2) * 10.0D / 300.0D);
final int partial = MathHelper.ceiling_double_int((double)airOverrideValue * 10.0D / 300.0D) - full;
final int full = MathHelper.ceil((double) (airOverrideValue - 2) * 10.0D / 300.0D);
final int partial = MathHelper.ceil((double) airOverrideValue * 10.0D / 300.0D) - full;

for (int i = 0; i < full + partial; ++i)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ private void renderBossGlow(float renderTick)
mobsmap.keySet().stream().filter(ent -> ent.isInRangeToRenderDist(curPos.squareDistanceTo(ent.getPositionVector()))
&& (ent.ignoreFrustumCheck || f.isBoundingBoxInFrustum(ent.getEntityBoundingBox()))
&& ent.isEntityAlive()).forEach(ent -> mc.renderGlobal.spawnParticle(EnumParticleTypes.SPELL_MOB.getParticleID(),
EnumParticleTypes.SPELL_MOB.getShouldIgnoreRange(), ent.posX + (ent.worldObj.rand.nextDouble() - 0.5D) * (double) ent.width,
ent.posY + ent.worldObj.rand.nextDouble() * (double) ent.height - 0.25D,
ent.posZ + (ent.worldObj.rand.nextDouble() - 0.5D) * (double) ent.width,
(ent.worldObj.rand.nextDouble() - 0.5D) * 2.0D,
-ent.worldObj.rand.nextDouble(),
(ent.worldObj.rand.nextDouble() - 0.5D) * 2.0D));
EnumParticleTypes.SPELL_MOB.getShouldIgnoreRange(), ent.posX + (ent.world.rand.nextDouble() - 0.5D) * (double) ent.width,
ent.posY + ent.world.rand.nextDouble() * (double) ent.height - 0.25D,
ent.posZ + (ent.world.rand.nextDouble() - 0.5D) * (double) ent.width,
(ent.world.rand.nextDouble() - 0.5D) * 2.0D,
-ent.world.rand.nextDouble(),
(ent.world.rand.nextDouble() - 0.5D) * 2.0D));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ public EntityEventHandler()
Configuration config = InfernalMobsCore.instance().config;

config.load();
antiMobFarm =
config.get(Configuration.CATEGORY_GENERAL, "AntiMobfarmingEnabled", true,
"Anti Mob farming mechanic. Might cause overhead if enabled.").getBoolean(true);
mobFarmCheckIntervals =
config.get(Configuration.CATEGORY_GENERAL, "AntiMobFarmCheckInterval", 30,
"time in seconds between mob check intervals. Higher values cost more performance, but might be more accurate.").getInt() * 1000L;
mobFarmDamageTrigger =
(float) config.get(Configuration.CATEGORY_GENERAL, "mobFarmDamageThreshold", 150D,
"Damage in chunk per interval that triggers anti farm effects").getDouble(150D);
antiMobFarm = config.get(Configuration.CATEGORY_GENERAL, "AntiMobfarmingEnabled", true, "Anti Mob farming mechanic. Might cause overhead if enabled.").getBoolean(true);
mobFarmCheckIntervals = config
.get(Configuration.CATEGORY_GENERAL, "AntiMobFarmCheckInterval", 30, "time in seconds between mob check intervals. Higher values cost more performance, but might be more accurate.")
.getInt() * 1000L;
mobFarmDamageTrigger = (float) config.get(Configuration.CATEGORY_GENERAL, "mobFarmDamageThreshold", 150D, "Damage in chunk per interval that triggers anti farm effects").getDouble(150D);
config.save();

damageMap = new HashMap<>();
Expand All @@ -76,7 +72,7 @@ public void onEntityJoinedWorld(EntityJoinWorldEvent event)
@SubscribeEvent
public void onEntityLivingDeath(LivingDeathEvent event)
{
if (!event.getEntity().worldObj.isRemote)
if (!event.getEntity().world.isRemote)
{
MobModifier mod = InfernalMobsCore.getMobModifiers(event.getEntityLiving());
if (mod != null)
Expand All @@ -92,7 +88,7 @@ public void onEntityLivingDeath(LivingDeathEvent event)
@SubscribeEvent
public void onEntityLivingSetAttackTarget(LivingSetAttackTargetEvent event)
{
if (!event.getEntity().worldObj.isRemote)
if (!event.getEntity().world.isRemote)
{
MobModifier mod = InfernalMobsCore.getMobModifiers(event.getEntityLiving());
if (mod != null)
Expand Down Expand Up @@ -140,10 +136,11 @@ public void onEntityLivingHurt(LivingHurtEvent event)
if (antiMobFarm)
{
/*
* check for an environmental/automated damage type, aka mob farms
* check for an environmental/automated damage type, aka mob
* farms
*/
if (event.getSource() == DamageSource.cactus || event.getSource() == DamageSource.drown || event.getSource() == DamageSource.fall
|| event.getSource() == DamageSource.inWall || event.getSource() == DamageSource.lava || event.getSource().getEntity() instanceof FakePlayer)
if (event.getSource() == DamageSource.CACTUS || event.getSource() == DamageSource.DROWN || event.getSource() == DamageSource.FALL || event.getSource() == DamageSource.IN_WALL
|| event.getSource() == DamageSource.LAVA || event.getSource().getEntity() instanceof FakePlayer)
{
Tuple<Integer, Integer> cpair = new Tuple<Integer, Integer>((int) event.getEntityLiving().posX, (int) event.getEntityLiving().posZ);
Float value = damageMap.get(cpair);
Expand Down Expand Up @@ -173,7 +170,7 @@ public void onEntityLivingHurt(LivingHurtEvent event)
@SubscribeEvent
public void onEntityLivingFall(LivingFallEvent event)
{
if (!event.getEntity().worldObj.isRemote)
if (!event.getEntity().world.isRemote)
{
MobModifier mod = InfernalMobsCore.getMobModifiers(event.getEntityLiving());
if (mod != null)
Expand All @@ -186,7 +183,7 @@ public void onEntityLivingFall(LivingFallEvent event)
@SubscribeEvent
public void onEntityLivingJump(LivingEvent.LivingJumpEvent event)
{
if (!event.getEntity().worldObj.isRemote)
if (!event.getEntity().world.isRemote)
{
MobModifier mod = InfernalMobsCore.getMobModifiers(event.getEntityLiving());
if (mod != null)
Expand All @@ -199,7 +196,7 @@ public void onEntityLivingJump(LivingEvent.LivingJumpEvent event)
@SubscribeEvent
public void onEntityLivingUpdate(LivingEvent.LivingUpdateEvent event)
{
if (!event.getEntityLiving().worldObj.isRemote)
if (!event.getEntityLiving().world.isRemote)
{
MobModifier mod = InfernalMobsCore.getMobModifiers(event.getEntityLiving());
if (mod != null)
Expand All @@ -226,12 +223,11 @@ public void onEntityLivingUpdate(LivingEvent.LivingUpdateEvent event)

if (maxC != null)
{
System.out.println("Infernal Mobs AntiMobFarm damage check, max detected chunk damage value " + maxDamage + " near coords "
+ maxC.getFirst() + ", " + maxC.getSecond());
System.out.println("Infernal Mobs AntiMobFarm damage check, max detected chunk damage value " + maxDamage + " near coords " + maxC.getFirst() + ", " + maxC.getSecond());
if (maxDamage > mobFarmDamageTrigger)
{
MinecraftForge.EVENT_BUS.post(new MobFarmDetectedEvent(event.getEntityLiving().worldObj.getChunkFromChunkCoords(maxC.getFirst(),
maxC.getSecond()), mobFarmCheckIntervals, maxDamage));
MinecraftForge.EVENT_BUS
.post(new MobFarmDetectedEvent(event.getEntityLiving().world.getChunkFromChunkCoords(maxC.getFirst(), maxC.getSecond()), mobFarmCheckIntervals, maxDamage));
}
}
damageMap.clear();
Expand All @@ -257,7 +253,7 @@ public MobFarmDetectedEvent(Chunk chunk, long ti, float td)
@SubscribeEvent
public void onEntityLivingDrops(LivingDropsEvent event)
{
if (!event.getEntity().worldObj.isRemote)
if (!event.getEntity().world.isRemote)
{
MobModifier mod = InfernalMobsCore.getMobModifiers(event.getEntityLiving());
if (mod != null)
Expand Down
Loading

0 comments on commit 9a3e890

Please sign in to comment.