Skip to content

Commit

Permalink
Fix #1862: don't tick shield blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
josephcsible committed Dec 27, 2018
1 parent ed49e3e commit 9cfbef7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,16 @@ private boolean checkPlayerCD(World world, BlockPos pos, EntityPlayer entity) {

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
NoTickShieldBlockTileEntity shieldBlockTileEntity = (NoTickShieldBlockTileEntity) world.getTileEntity(pos);
if (!(entity instanceof EntityLivingBase)) {
NoTickShieldBlockTileEntity shieldBlockTileEntity = (NoTickShieldBlockTileEntity) world.getTileEntity(pos);
int cdData = shieldBlockTileEntity.getCollisionData();
if ((cdData & META_ITEMS) == 0) {
// Items should be able to pass through. We just move the entity to below this block.
entity.setPosition(entity.posX, entity.posY-1, entity.posZ);
}
}

// Possibly check for damage.
shieldBlockTileEntity.handleDamage(entity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
Expand Down Expand Up @@ -171,4 +172,7 @@ public SPacketUpdateTileEntity getUpdatePacket() {
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
readFromNBT(packet.getNbtCompound());
}

public void handleDamage(Entity entity) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,15 @@
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.List;

public class TickShieldBlockTileEntity extends NoTickShieldBlockTileEntity implements ITickable {
public class TickShieldBlockTileEntity extends NoTickShieldBlockTileEntity {

@Override
public void update() {
if (!getWorld().isRemote) {
if (damageBits != 0) {
handleDamage();
}
}
}

private void handleDamage() {
if (getWorld().getTotalWorldTime() % 10 != 0) {
public void handleDamage(Entity entity) {
if (damageBits == 0 || getWorld().isRemote || getWorld().getTotalWorldTime() % 10 != 0) {
return;
}
if (beamBox == null) {
Expand All @@ -35,8 +26,7 @@ private void handleDamage() {
if (shieldBlock != null) {
ShieldTEBase shieldTileEntity = (ShieldTEBase) getWorld().getTileEntity(shieldBlock);
if (shieldTileEntity != null) {
List<Entity> l = getWorld().getEntitiesWithinAABB(Entity.class, beamBox);
for (Entity entity : l) {
if (entity.getEntityBoundingBox().intersects(beamBox)) {
if ((damageBits & AbstractShieldBlock.META_HOSTILE) != 0 && entity instanceof IMob) {
if (checkEntityDamage(shieldTileEntity, HostileFilter.HOSTILE)) {
shieldTileEntity.applyDamageToEntity(entity);
Expand Down

0 comments on commit 9cfbef7

Please sign in to comment.