1.0.14
All checks were successful
RelicCraft/pipeline/head This commit looks good

Fix Spawn Protection
This commit is contained in:
TheBrokenRail 2020-04-09 16:48:02 -04:00
parent 221f6e2336
commit 378a0662c8
3 changed files with 48 additions and 20 deletions

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
**1.0.14**
* Fix Spawn Protection
**1.0.13** **1.0.13**
* Fix Bugs * Fix Bugs

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.7.10+build.191 fabric_loader_version = 0.7.10+build.191
# Mod Properties # Mod Properties
mod_version = 1.0.13 mod_version = 1.0.14
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
archives_base_name = reliccraft archives_base_name = reliccraft

View File

@ -9,9 +9,12 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SpawnType; import net.minecraft.entity.SpawnType;
import net.minecraft.entity.mob.ZombieEntity; import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.thrown.ThrownPotionEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; 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.math.BlockPos;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -78,6 +81,9 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { 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,11 +95,13 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { public void execute(World world, LivingEntity attacker, BlockPos pos) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos) && world.canPlayerModifyAt((PlayerEntity) attacker, attacker.getBlockPos().down())) {
BlockState state1 = world.getBlockState(attacker.getBlockPos().down()); BlockState state1 = world.getBlockState(attacker.getBlockPos().down());
BlockState state2 = world.getBlockState(pos); BlockState state2 = world.getBlockState(pos);
world.setBlockState(attacker.getBlockPos().down(), state2); world.setBlockState(attacker.getBlockPos().down(), state2);
world.setBlockState(pos, state1); world.setBlockState(pos, state1);
} }
}
@Override @Override
public int getCost() { public int getCost() {
@ -109,16 +117,20 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, Entity target) { public void execute(World world, LivingEntity attacker, Entity target) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, target.getBlockPos())) {
target.remove(); target.remove();
target.kill(); target.kill();
world.setBlockState(target.getBlockPos(), Blocks.DIRT.getDefaultState()); world.setBlockState(target.getBlockPos(), Blocks.DIRT.getDefaultState());
} }
}
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { public void execute(World world, LivingEntity attacker, BlockPos pos) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
world.setBlockState(pos, Blocks.DIRT.getDefaultState()); world.setBlockState(pos, Blocks.DIRT.getDefaultState());
} }
} }
}
public static class NetherAction implements Action { public static class NetherAction implements Action {
@Override @Override
@ -137,9 +149,11 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { public void execute(World world, LivingEntity attacker, BlockPos pos) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
world.setBlockState(pos, Blocks.LAVA.getDefaultState()); world.setBlockState(pos, Blocks.LAVA.getDefaultState());
} }
} }
}
public static class EndAction implements Action { public static class EndAction implements Action {
@Override @Override
@ -154,9 +168,11 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { public void execute(World world, LivingEntity attacker, BlockPos pos) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
world.setBlockState(pos, Blocks.END_STONE.getDefaultState()); world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
} }
} }
}
public static class DiamondAction extends ConversionAction { public static class DiamondAction extends ConversionAction {
@Override @Override
@ -212,7 +228,7 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { 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()); world.setBlockState(pos, getConvertedBlock().getDefaultState());
} }
} }
@ -248,21 +264,25 @@ public class Actions {
public static class BedrockAction implements Action { public static class BedrockAction implements Action {
@Override @Override
public int getCost() { public int getCost() {
return 90; return 95;
} }
@Override @Override
public void execute(World world, LivingEntity attacker, Entity target) { public void execute(World world, LivingEntity attacker, Entity target) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, attacker.getBlockPos())) {
target.remove(); target.remove();
target.kill(); target.kill();
world.setBlockState(target.getBlockPos(), Blocks.BEDROCK.getDefaultState()); world.setBlockState(target.getBlockPos(), Blocks.BEDROCK.getDefaultState());
} }
}
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { public void execute(World world, LivingEntity attacker, BlockPos pos) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
world.setBlockState(pos, Blocks.BEDROCK.getDefaultState()); world.setBlockState(pos, Blocks.BEDROCK.getDefaultState());
} }
} }
}
public static class HealAction implements Action { public static class HealAction implements Action {
@Override @Override
@ -279,6 +299,9 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { 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,10 +353,12 @@ public class Actions {
@Override @Override
public void execute(World world, LivingEntity attacker, BlockPos pos) { public void execute(World world, LivingEntity attacker, BlockPos pos) {
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
int blockID = new Random().nextInt(Registry.BLOCK.getIds().size()); int blockID = new Random().nextInt(Registry.BLOCK.getIds().size());
Block block = Registry.BLOCK.get(blockID); Block block = Registry.BLOCK.get(blockID);
world.setBlockState(pos, block.getDefaultState()); world.setBlockState(pos, block.getDefaultState());
} }
}
@Override @Override
public int getCost() { public int getCost() {