diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e6e904..dd971da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +**1.0.14** +* Fix Spawn Protection + **1.0.13** * Fix Bugs diff --git a/gradle.properties b/gradle.properties index 3a06eb0..a6a7b2e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G fabric_loader_version = 0.7.10+build.191 # Mod Properties - mod_version = 1.0.13 + mod_version = 1.0.14 maven_group = com.thebrokenrail archives_base_name = reliccraft diff --git a/src/main/java/com/thebrokenrail/reliccraft/data/Actions.java b/src/main/java/com/thebrokenrail/reliccraft/data/Actions.java index d640b53..a9b4295 100644 --- a/src/main/java/com/thebrokenrail/reliccraft/data/Actions.java +++ b/src/main/java/com/thebrokenrail/reliccraft/data/Actions.java @@ -9,9 +9,12 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SpawnType; import net.minecraft.entity.mob.ZombieEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.thrown.ThrownPotionEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.potion.PotionUtil; +import net.minecraft.potion.Potions; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; @@ -78,6 +81,9 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { + ThrownPotionEntity entity = new ThrownPotionEntity(world, pos.getX(), pos.getY(), pos.getZ()); + entity.setItemStack(PotionUtil.setPotion(new ItemStack(Items.LINGERING_POTION), Potions.STRONG_HARMING)); + world.spawnEntity(entity); } } @@ -89,10 +95,12 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { - BlockState state1 = world.getBlockState(attacker.getBlockPos().down()); - BlockState state2 = world.getBlockState(pos); - world.setBlockState(attacker.getBlockPos().down(), state2); - world.setBlockState(pos, state1); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos) && world.canPlayerModifyAt((PlayerEntity) attacker, attacker.getBlockPos().down())) { + BlockState state1 = world.getBlockState(attacker.getBlockPos().down()); + BlockState state2 = world.getBlockState(pos); + world.setBlockState(attacker.getBlockPos().down(), state2); + world.setBlockState(pos, state1); + } } @Override @@ -109,14 +117,18 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, Entity target) { - target.remove(); - target.kill(); - world.setBlockState(target.getBlockPos(), Blocks.DIRT.getDefaultState()); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, target.getBlockPos())) { + target.remove(); + target.kill(); + world.setBlockState(target.getBlockPos(), Blocks.DIRT.getDefaultState()); + } } @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { - world.setBlockState(pos, Blocks.DIRT.getDefaultState()); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) { + world.setBlockState(pos, Blocks.DIRT.getDefaultState()); + } } } @@ -137,7 +149,9 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { - world.setBlockState(pos, Blocks.LAVA.getDefaultState()); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) { + world.setBlockState(pos, Blocks.LAVA.getDefaultState()); + } } } @@ -154,7 +168,9 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { - world.setBlockState(pos, Blocks.END_STONE.getDefaultState()); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) { + world.setBlockState(pos, Blocks.END_STONE.getDefaultState()); + } } } @@ -212,7 +228,7 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { - if (world.getBlockState(pos).getBlock() == getTargetBlock()) { + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos) && world.getBlockState(pos).getBlock() == getTargetBlock()) { world.setBlockState(pos, getConvertedBlock().getDefaultState()); } } @@ -248,19 +264,23 @@ public class Actions { public static class BedrockAction implements Action { @Override public int getCost() { - return 90; + return 95; } @Override public void execute(World world, LivingEntity attacker, Entity target) { - target.remove(); - target.kill(); - world.setBlockState(target.getBlockPos(), Blocks.BEDROCK.getDefaultState()); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, attacker.getBlockPos())) { + target.remove(); + target.kill(); + world.setBlockState(target.getBlockPos(), Blocks.BEDROCK.getDefaultState()); + } } @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { - world.setBlockState(pos, Blocks.BEDROCK.getDefaultState()); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) { + world.setBlockState(pos, Blocks.BEDROCK.getDefaultState()); + } } } @@ -279,6 +299,9 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { + ThrownPotionEntity entity = new ThrownPotionEntity(world, pos.getX(), pos.getY(), pos.getZ()); + entity.setItemStack(PotionUtil.setPotion(new ItemStack(Items.LINGERING_POTION), Potions.STRONG_HEALING)); + world.spawnEntity(entity); } } @@ -330,9 +353,11 @@ public class Actions { @Override public void execute(World world, LivingEntity attacker, BlockPos pos) { - int blockID = new Random().nextInt(Registry.BLOCK.getIds().size()); - Block block = Registry.BLOCK.get(blockID); - world.setBlockState(pos, block.getDefaultState()); + if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) { + int blockID = new Random().nextInt(Registry.BLOCK.getIds().size()); + Block block = Registry.BLOCK.get(blockID); + world.setBlockState(pos, block.getDefaultState()); + } } @Override