fix #13 this time for real

This commit is contained in:
Flemmli97 2020-11-07 13:44:26 +01:00
parent d4e49e1e58
commit bf69a0a1dd
3 changed files with 7 additions and 4 deletions

View File

@ -1,3 +1,7 @@
Flan 1.1.4
======================
- Directly check player class for item usage. So fake players get ignored.
Flan 1.1.3
======================
- Ignore item usage with non player (e.g. with modded machines). Fix #12

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2G
loader_version=0.9.1+build.205
# Mod Properties
mod_version = 1.1.3
mod_version = 1.1.4
maven_group = com.flemmli97.flan
archives_base_name = flan

View File

@ -73,7 +73,8 @@ public class ItemInteractEvents {
private static final Set<Item> blackListedItems = Sets.newHashSet(Items.COMPASS, Items.FILLED_MAP, Items.FIREWORK_ROCKET);
public static ActionResult onItemUseBlock(ItemUsageContext context) {
if (context.getWorld().isClient || context.getStack().isEmpty())
//Check for Fakeplayer. Since there is no api for that directly check the class
if (!(context.getPlayer() instanceof ServerPlayerEntity) || !context.getPlayer().getClass().equals(ServerPlayerEntity.class) || context.getStack().isEmpty())
return ActionResult.PASS;
ClaimStorage storage = ClaimStorage.get((ServerWorld) context.getWorld());
BlockPos placePos = new ItemPlacementContext(context).getBlockPos();
@ -84,8 +85,6 @@ public class ItemInteractEvents {
return ActionResult.PASS;
boolean actualInClaim = !(claim instanceof Claim) || placePos.getY() >= ((Claim) claim).getDimensions()[4];
ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer();
if(player==null)
return ActionResult.PASS;
if (context.getStack().getItem() == Items.END_CRYSTAL) {
if (claim.canInteract(player, EnumPermission.ENDCRYSTALPLACE, placePos, false))
return ActionResult.PASS;