Merge remote-tracking branch 'origin/master'

This commit is contained in:
noil 2019-11-17 17:52:07 -05:00
commit e0a245c60e
1 changed files with 28 additions and 21 deletions

View File

@ -11,10 +11,16 @@ import me.rigamortis.seppuku.api.util.MathUtil;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.value.OptionalValue;
import me.rigamortis.seppuku.impl.module.player.FreeCamModule;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockObsidian;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
@ -74,8 +80,6 @@ public final class ObsidianReplaceModule extends Module {
if (pos != null) {
final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
if (dist <= 5.0f) {
final Block block = mc.world.getBlockState(pos).getBlock();
if (block instanceof BlockAir || block instanceof BlockLiquid) {
if (this.valid(pos)) {
this.place(pos);
valid = true;
@ -83,7 +87,6 @@ public final class ObsidianReplaceModule extends Module {
}
}
}
}
if (valid) {
mc.player.inventory.currentItem = this.lastSlot;
@ -112,15 +115,12 @@ public final class ObsidianReplaceModule extends Module {
if (pos != null) {
final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
if (dist <= 5.0f) {
final Block block = mc.world.getBlockState(pos).getBlock();
if (block instanceof BlockAir || block instanceof BlockLiquid) {
if (this.valid(pos)) {
return true;
}
}
}
}
}
return false;
}
@ -337,6 +337,16 @@ public final class ObsidianReplaceModule extends Module {
private boolean valid(BlockPos pos) {
final Block block = mc.world.getBlockState(pos).getBlock();
if (!(block instanceof BlockAir) && !(block instanceof BlockLiquid)) {
return false;
}
final List<Entity> invalidEntities = mc.world.getEntitiesInAABBexcluding(null,
new AxisAlignedBB(pos), entity -> !(entity instanceof EntityItem) &&
!(entity instanceof EntityXPOrb));
if (!invalidEntities.isEmpty())
return false;
final Block up = mc.world.getBlockState(pos.add(0, 1, 0)).getBlock();
final Block down = mc.world.getBlockState(pos.add(0, -1, 0)).getBlock();
final Block north = mc.world.getBlockState(pos.add(0, 0, -1)).getBlock();
@ -344,14 +354,11 @@ public final class ObsidianReplaceModule extends Module {
final Block east = mc.world.getBlockState(pos.add(1, 0, 0)).getBlock();
final Block west = mc.world.getBlockState(pos.add(-1, 0, 0)).getBlock();
return (block instanceof BlockAir)
&& mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos)).isEmpty()
&& ((up != null && up != Blocks.AIR && !(up instanceof BlockLiquid))
|| (down != null && down != Blocks.AIR && !(down instanceof BlockLiquid))
|| (north != null && north != Blocks.AIR && !(north instanceof BlockLiquid))
|| (south != null && south != Blocks.AIR && !(south instanceof BlockLiquid))
|| (east != null && east != Blocks.AIR && !(east instanceof BlockLiquid))
|| (west != null && west != Blocks.AIR && !(west instanceof BlockLiquid)));
return ((up != Blocks.AIR && !(up instanceof BlockLiquid))
|| (down != Blocks.AIR && !(down instanceof BlockLiquid))
|| (north != Blocks.AIR && !(north instanceof BlockLiquid))
|| (south != Blocks.AIR && !(south instanceof BlockLiquid))
|| (east != Blocks.AIR && !(east instanceof BlockLiquid))
|| (west != Blocks.AIR && !(west instanceof BlockLiquid)));
}
}