Added peaceful-friendly settings for the Sentient Mimics
This commit is contained in:
parent
fc6f99df75
commit
215b337f71
|
@ -31,6 +31,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.block.BlockMimic;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
|
@ -134,6 +135,8 @@ public class EntityMimic extends EntityMob
|
|||
mimic.dropItemsOnBreak = dropItemsOnBreak;
|
||||
mimic.refreshTileEntity();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -147,6 +150,40 @@ public class EntityMimic extends EntityMob
|
|||
this.metaOfReplacedBlock = metaOfReplacedBlock;
|
||||
}
|
||||
|
||||
public void reformIntoMimicBlock()
|
||||
{
|
||||
BlockPos centerPos = this.getPosition();
|
||||
|
||||
int horizontalRadius = 1;
|
||||
int verticalRadius = 1;
|
||||
|
||||
for (int hR = 0; hR <= horizontalRadius; hR++)
|
||||
{
|
||||
for (int vR = 0; vR <= verticalRadius; vR++)
|
||||
{
|
||||
for (int i = -hR; i <= hR; i++)
|
||||
{
|
||||
for (int k = -hR; k <= hR; k++)
|
||||
{
|
||||
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1))
|
||||
{
|
||||
if (!(Math.abs(i) == hR || Math.abs(k) == hR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPos newPos = centerPos.add(i, j, k);
|
||||
if (spawnMimicBlockAtPosition(worldObj, newPos))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource cause)
|
||||
{
|
||||
|
@ -220,6 +257,12 @@ public class EntityMimic extends EntityMob
|
|||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (!this.worldObj.isRemote && this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)
|
||||
{
|
||||
reformIntoMimicBlock();
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.util.ITickable;
|
|||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import WayofTime.bloodmagic.block.BlockMimic;
|
||||
|
@ -89,7 +90,7 @@ public class TileMimic extends TileInventory implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
if (this.getBlockMetadata() == BlockMimic.sentientMimicMeta && !(mimicedTile instanceof IInventory))
|
||||
if (this.getBlockMetadata() == BlockMimic.sentientMimicMeta && worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(mimicedTile instanceof IInventory))
|
||||
{
|
||||
AxisAlignedBB bb = new AxisAlignedBB(this.getPos()).expand(playerCheckRadius, playerCheckRadius, playerCheckRadius);
|
||||
List<EntityPlayer> playerList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, bb);
|
||||
|
@ -181,6 +182,7 @@ public class TileMimic extends TileInventory implements ITickable
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
return spawnMimicEntity(player);
|
||||
default:
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
|
@ -241,6 +243,11 @@ public class TileMimic extends TileInventory implements ITickable
|
|||
|
||||
public boolean spawnMimicEntity(EntityPlayer target)
|
||||
{
|
||||
if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.getStackInSlot(0) == null || worldObj.isRemote)
|
||||
{
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue