Fixed another a few forcefield exploits
- ender pearl protection - quarry and cie. - EMP tower staking
This commit is contained in:
parent
8096ef7a3d
commit
73343649d6
3 changed files with 58 additions and 3 deletions
|
@ -131,7 +131,16 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
|
|||
}
|
||||
// EMP tower = 3k Energy, 60 radius
|
||||
// EMP explosive = 3k Energy, 50 radius
|
||||
onEMP(world, x, y, z, explosiveEMP.getRadius() / 100.0F);
|
||||
if (explosiveEMP.getRadius() == 60.0F) {// compensate tower stacking effect
|
||||
onEMP(world, x, y, z, 0.02F);
|
||||
} else if (explosiveEMP.getRadius() == 50.0F) {
|
||||
onEMP(world, x, y, z, 0.70F);
|
||||
} else {
|
||||
WarpDrive.logger.warn(String.format("EMP received @ DIM%d (%d %d %d) from %s with energy %d and unsupported radius %.1f",
|
||||
world.provider.dimensionId, x, y, z,
|
||||
explosiveEMP, explosiveEMP.getEnergy(), explosiveEMP.getRadius()));
|
||||
onEMP(world, x, y, z, explosiveEMP.getRadius() / 100.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,7 +153,16 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
|
|||
}
|
||||
// EMP tower = 3k Energy, 60 radius
|
||||
// EMP explosive = 3k Energy, 50 radius
|
||||
onEMP(world, x, y, z, explosiveEMP.getRadius() / 100.0F);
|
||||
if (explosiveEMP.getRadius() == 60.0F) {// compensate tower stacking effect
|
||||
onEMP(world, x, y, z, 0.02F);
|
||||
} else if (explosiveEMP.getRadius() == 50.0F) {
|
||||
onEMP(world, x, y, z, 0.70F);
|
||||
} else {
|
||||
WarpDrive.logger.warn(String.format("EMP received @ DIM%d (%d %d %d) from %s with energy %d and unsupported radius %.1f",
|
||||
world.provider.dimensionId, x, y, z,
|
||||
explosiveEMP, explosiveEMP.getEnergy(), explosiveEMP.getRadius()));
|
||||
onEMP(world, x, y, z, explosiveEMP.getRadius() / 100.0F);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEMP(World world, final int x, final int y, final int z, final float efficiency) {
|
||||
|
|
|
@ -50,6 +50,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
|
|||
setStepSound(Block.soundTypeCloth);
|
||||
setBlockName("warpdrive.forcefield.block" + tier);
|
||||
setBlockTextureName("warpdrive:forcefield/forcefield");
|
||||
setBlockUnbreakable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,6 +149,9 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
|
|||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
ForceFieldSetup forceFieldSetup = getForceFieldSetup(world, x, y, z);
|
||||
if (forceFieldSetup != null) {
|
||||
forceFieldSetup.onEntityEffect(world, x, y, z, entityPlayer);
|
||||
|
@ -360,8 +364,9 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
|
|||
super.onBlockExploded(world, x, y, z, explosion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEMP(World world, final int x, final int y, final int z, final float efficiency) {
|
||||
if (efficiency > 0.0F) {
|
||||
if (efficiency * (1.0F - 0.20F * (tier - 1)) > world.rand.nextFloat()) {
|
||||
downgrade(world, x, y, z);
|
||||
}
|
||||
// already handled => no ancestor call
|
||||
|
|
|
@ -3,6 +3,7 @@ package cr0s.warpdrive.event;
|
|||
import cr0s.warpdrive.BreathingManager;
|
||||
import cr0s.warpdrive.Commons;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.block.forcefield.BlockForceField;
|
||||
import cr0s.warpdrive.data.CelestialObjectManager;
|
||||
import cr0s.warpdrive.config.Dictionary;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
@ -13,16 +14,19 @@ import cr0s.warpdrive.world.SpaceTeleporter;
|
|||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
|
||||
|
@ -283,4 +287,32 @@ public class LivingHandler {
|
|||
motionY, event.distance, entityLivingBase, event.isCanceled()));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEnderTeleport(final EnderTeleportEvent event) {
|
||||
if ( event.entityLiving == null
|
||||
|| event.entityLiving.worldObj.isRemote ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final World world = event.entityLiving.worldObj;
|
||||
final int x = MathHelper.floor_double(event.targetX);
|
||||
final int y = MathHelper.floor_double(event.targetY);
|
||||
final int z = MathHelper.floor_double(event.targetZ);
|
||||
|
||||
for (int xLoop = x - 1; xLoop <= x + 1; xLoop++) {
|
||||
for (int zLoop = z - 1; zLoop <= z + 1; zLoop++) {
|
||||
for (int yLoop = y - 1; yLoop <= y + 1; yLoop++) {
|
||||
if (yLoop <= 0 || yLoop > 255) {
|
||||
continue;
|
||||
}
|
||||
Block block = world.getBlock(xLoop, yLoop, zLoop);
|
||||
if (block instanceof BlockForceField) {
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue