Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObsidianReplace ignore non LivingBase Entities #8

Merged
5 commits merged into from
Nov 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
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;
Expand Down Expand Up @@ -74,12 +80,9 @@ public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
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;
}
if (this.valid(pos)) {
this.place(pos);
valid = true;
}
}
}
Expand Down Expand Up @@ -112,11 +115,8 @@ private boolean canPlace() {
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;
}
if (this.valid(pos)) {
return true;
}
}
}
Expand Down Expand Up @@ -337,16 +337,24 @@ private int findStackHotbar(Block type) {
private boolean valid(BlockPos pos) {
final Block block = mc.world.getBlockState(pos).getBlock();

if (!(block instanceof BlockAir) && !(block instanceof BlockLiquid)) {
return false;
}

for (Entity entity : mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos))) {
if (!(entity instanceof EntityItem) && !(entity instanceof EntityXPOrb)) {
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();
final Block south = mc.world.getBlockState(pos.add(0, 0, 1)).getBlock();
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))
return ((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))
Expand Down