-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
167 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/java/net/pottx/mobsenhancement/mixin/EndermanEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package net.pottx.mobsenhancement.mixin; | ||
|
||
import btw.entity.mob.EndermanEntity; | ||
import net.minecraft.src.*; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(EndermanEntity.class) | ||
public class EndermanEntityMixin extends EntityEnderman { | ||
@Shadow protected int teleportDelay; | ||
|
||
public EndermanEntityMixin(World par1World) { | ||
super(par1World); | ||
} | ||
|
||
@Inject( | ||
method = "onLivingUpdate", | ||
at = @At(value = "INVOKE", target = "Lbtw/entity/mob/EndermanEntity;entityMobOnLivingUpdate()V") | ||
) | ||
private void updateEnemyTeleport(CallbackInfo ci) | ||
{ | ||
if (!this.worldObj.isRemote && this.isEntityAlive() && this.entityToAttack != null) { | ||
if (entityToAttack.getDistanceSqToEntity(this) > 6.0D && entityToAttack.getDistanceSqToEntity(this) < 64D) { | ||
if (teleportDelay++ >= 120 && this.teleportEnemy()) { | ||
this.teleportDelay = 0; | ||
} | ||
} else if (entityToAttack.getDistanceSqToEntity(this) < 256D) { | ||
this.teleportDelay = 0; | ||
} | ||
} | ||
} | ||
|
||
protected boolean teleportEnemy() { | ||
if (this.entityToAttack != null) { | ||
Entity target = this.entityToAttack; | ||
Vec3 vec = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX - target.posX, this.boundingBox.minY + (double)(this.height / 2.0F) - target.posY + (double)target.getEyeHeight(), this.posZ - target.posZ); | ||
vec = vec.normalize(); | ||
double x0 = target.posX; | ||
double y0 = target.posY; | ||
double z0 = target.posZ; | ||
target.posX = x0 + (this.rand.nextDouble() - 0.5D) * 8.0D + vec.xCoord * 0.8D; | ||
target.posY = y0 + (double)(this.rand.nextInt(16) - 8) + vec.yCoord * 0.8D; | ||
target.posZ = z0 + (this.rand.nextDouble() - 0.5D) * 8.0D + vec.zCoord * 0.8D; | ||
int xb = MathHelper.floor_double(target.posX); | ||
int yb = MathHelper.floor_double(target.posY); | ||
int zb = MathHelper.floor_double(target.posZ); | ||
int blockId; | ||
|
||
if (this.worldObj.blockExists(xb, yb, zb)) { | ||
boolean canTeleport = false; | ||
|
||
while (!canTeleport && yb > 0) { | ||
blockId = this.worldObj.getBlockId(xb, yb, zb); | ||
if (blockId != 0 && Block.blocksList[blockId].blockMaterial.blocksMovement()) { | ||
canTeleport = true; | ||
for (int i = 1; i <= MathHelper.ceiling_float_int(target.height); i++) { | ||
blockId = this.worldObj.getBlockId(xb, yb + i, zb); | ||
if (blockId != 0 && Block.blocksList[blockId].blockMaterial.blocksMovement()) { | ||
canTeleport = false; | ||
target.posY -= MathHelper.ceiling_float_int(target.height) + 1; | ||
yb -= MathHelper.ceiling_float_int(target.height) + 1; | ||
break; | ||
} | ||
} | ||
++target.posY; | ||
} | ||
else { | ||
--target.posY; | ||
--yb; | ||
} | ||
} | ||
|
||
if (canTeleport) { | ||
if (target instanceof EntityPlayer) { | ||
((EntityPlayer) target).setPositionAndUpdate(target.posX, target.posY, target.posZ); | ||
} else { | ||
target.setPosition(target.posX, target.posY, target.posZ); | ||
} | ||
|
||
short var30 = 128; | ||
for (blockId = 0; blockId < var30; ++blockId) { | ||
double var19 = (double)blockId / ((double)var30 - 1.0D); | ||
float var21 = (this.rand.nextFloat() - 0.5F) * 0.2F; | ||
float var22 = (this.rand.nextFloat() - 0.5F) * 0.2F; | ||
float var23 = (this.rand.nextFloat() - 0.5F) * 0.2F; | ||
double var24 = x0 + (target.posX - x0) * var19 + (this.rand.nextDouble() - 0.5D) * (double)target.width * 2.0D; | ||
double var26 = y0 + (target.posY - y0) * var19 + this.rand.nextDouble() * (double)target.height; | ||
double var28 = z0 + (target.posZ - z0) * var19 + (this.rand.nextDouble() - 0.5D) * (double)target.width * 2.0D; | ||
this.worldObj.spawnParticle("portal", var24, var26, var28, (double)var21, (double)var22, (double)var23); | ||
} | ||
this.worldObj.playSoundEffect(x0, y0, z0, "mob.endermen.portal", 1.0F, 1.0F); | ||
target.playSound("mob.endermen.portal", 1.0F, 1.0F); | ||
|
||
return true; | ||
} else { | ||
target.setPosition(x0, y0, z0); | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/net/pottx/mobsenhancement/mixin/EntityAnimalMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.pottx.mobsenhancement.mixin; | ||
|
||
import net.minecraft.src.*; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(EntityAnimal.class) | ||
public abstract class EntityAnimalMixin extends EntityAgeable { | ||
@Shadow public abstract void setRevengeTarget(EntityLiving targetEntity); | ||
|
||
@Unique | ||
private int pushedCounter = 0; | ||
|
||
public EntityAnimalMixin(World par1World) { | ||
super(par1World); | ||
} | ||
|
||
@Inject( | ||
method = "onLivingUpdate", | ||
at = @At(value = "TAIL") | ||
) | ||
private void updatePushed(CallbackInfo ci) { | ||
EntityPlayer player = (EntityPlayer) this.worldObj.findNearestEntityWithinAABB(EntityPlayer.class, this.boundingBox.expand(1.5D, 1D, 1.5D), this); | ||
if (player != null && this.boundingBox.expand(0.35D, 0.35D, 0.35D).intersectsWith(player.boundingBox)) { | ||
if (this.pushedCounter < 10) { | ||
++this.pushedCounter; | ||
} else { | ||
this.setRevengeTarget(player); | ||
} | ||
} else if (this.pushedCounter > 0) { | ||
this.pushedCounter = 0; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters