mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-03 19:06:39 +01:00
Added check to see if a user is allowed to place blocks in the given position to counteract issues with FTBChunks
This commit is contained in:
parent
932ff3bd01
commit
f3b6a684f9
1 changed files with 15 additions and 3 deletions
|
@ -109,7 +109,7 @@ public class BlockzapperItem extends ZapperItem {
|
||||||
continue;
|
continue;
|
||||||
if (!selectedState.isValidPosition(world, placed))
|
if (!selectedState.isValidPosition(world, placed))
|
||||||
continue;
|
continue;
|
||||||
if (!player.isCreative() && !canBreak(stack, world.getBlockState(placed), world, placed))
|
if (!player.isCreative() && !canBreak(stack, world.getBlockState(placed), world, placed,player))
|
||||||
continue;
|
continue;
|
||||||
if (!player.isCreative() && BlockHelper.findAndRemoveInInventory(selectedState, player, 1) == 0) {
|
if (!player.isCreative() && BlockHelper.findAndRemoveInInventory(selectedState, player, 1) == 0) {
|
||||||
player.getCooldownTracker()
|
player.getCooldownTracker()
|
||||||
|
@ -278,10 +278,13 @@ public class BlockzapperItem extends ZapperItem {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canBreak(ItemStack stack, BlockState state, World world, BlockPos pos) {
|
public static boolean canBreak(ItemStack stack, BlockState state, World world, BlockPos pos,PlayerEntity player) {
|
||||||
ComponentTier tier = getTier(Components.Body, stack);
|
ComponentTier tier = getTier(Components.Body, stack);
|
||||||
float blockHardness = state.getBlockHardness(world, pos);
|
float blockHardness = state.getBlockHardness(world, pos);
|
||||||
|
//If we can't change the block (e.g chunk protection)
|
||||||
|
if (!isAllowedToPlace(world,pos,player)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (blockHardness == -1)
|
if (blockHardness == -1)
|
||||||
return false;
|
return false;
|
||||||
if (tier == ComponentTier.None)
|
if (tier == ComponentTier.None)
|
||||||
|
@ -294,6 +297,15 @@ public class BlockzapperItem extends ZapperItem {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAllowedToPlace(World world, BlockPos pos,PlayerEntity player){
|
||||||
|
BlockSnapshot blocksnapshot = BlockSnapshot.getBlockSnapshot(world, pos);
|
||||||
|
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) {
|
||||||
|
blocksnapshot.restore(true, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getMaxAoe(ItemStack stack) {
|
public static int getMaxAoe(ItemStack stack) {
|
||||||
ComponentTier tier = getTier(Components.Amplifier, stack);
|
ComponentTier tier = getTier(Components.Amplifier, stack);
|
||||||
if (tier == ComponentTier.None)
|
if (tier == ComponentTier.None)
|
||||||
|
|
Loading…
Reference in a new issue