This commit is contained in:
parent
454647c599
commit
bd950a58b0
3 changed files with 20 additions and 19 deletions
|
@ -49,7 +49,7 @@ public class Area {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean does_intersect(BoundingBox c){
|
public boolean does_intersect(BoundingBox c){
|
||||||
return space.contains(c);
|
return space.intersects(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean get_action_bool(String action,String player_id){
|
public boolean get_action_bool(String action,String player_id){
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.pietru.cookie_utils.mixins;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.math.collision.BoundingBox;
|
import com.badlogic.gdx.math.collision.BoundingBox;
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
|
import finalforeach.cosmicreach.blockentities.BlockEntity;
|
||||||
import finalforeach.cosmicreach.blockentities.BlockEntitySign;
|
import finalforeach.cosmicreach.blockentities.BlockEntitySign;
|
||||||
import finalforeach.cosmicreach.entities.player.Player;
|
import finalforeach.cosmicreach.entities.player.Player;
|
||||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||||
|
@ -19,23 +20,22 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static net.pietru.cookie_utils.utils.block_util.isInt;
|
||||||
|
|
||||||
@Mixin(BlockEntitySign.class)
|
@Mixin(BlockEntitySign.class)
|
||||||
public class BlockEntitySignMixin {
|
public class BlockEntitySignMixin {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private String[] texts = new String[]{"", "", "", "", ""};
|
private String[] texts = new String[]{"", "", "", "", ""};
|
||||||
@Shadow
|
|
||||||
Zone zone;
|
|
||||||
@Shadow
|
|
||||||
int x;
|
|
||||||
@Shadow
|
|
||||||
int y;
|
|
||||||
@Shadow
|
|
||||||
int z;
|
|
||||||
|
|
||||||
@Inject(method = "onInteract", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onInteract", at = @At("HEAD"), cancellable = true)
|
||||||
private void event_onInteract(CallbackInfo ci, @Local Player player, @Local Zone zone){
|
private void event_onInteract(CallbackInfo ci, @Local Player player, @Local Zone zone){
|
||||||
if (texts[0].equals("[CLAIM]") && texts[2].isEmpty() && !player.isProne) {
|
if (texts[0].equals("[CLAIM]") && texts[2].isEmpty() && !player.isProne) {
|
||||||
|
BlockEntity be = (BlockEntity) (Object) this;
|
||||||
|
int x = be.getGlobalX();
|
||||||
|
int y = be.getGlobalY();
|
||||||
|
int z = be.getGlobalZ();
|
||||||
|
|
||||||
String ownerId = player.getAccount().getUniqueId();
|
String ownerId = player.getAccount().getUniqueId();
|
||||||
int c = Region.get_owned_areas(ownerId);
|
int c = Region.get_owned_areas(ownerId);
|
||||||
if (Permissions.has_perm(ownerId,"claims.limit."+(c+1))) {
|
if (Permissions.has_perm(ownerId,"claims.limit."+(c+1))) {
|
||||||
|
@ -46,6 +46,7 @@ public class BlockEntitySignMixin {
|
||||||
boolean can_claim = true;
|
boolean can_claim = true;
|
||||||
for (int i = 0; (i< Region.areas.size && can_claim); i++){
|
for (int i = 0; (i< Region.areas.size && can_claim); i++){
|
||||||
Area a = Region.areas.get(i);
|
Area a = Region.areas.get(i);
|
||||||
|
System.out.println(a.does_intersect(test)+"_"+a.name);
|
||||||
if (a.piority>=0 && a.does_intersect(test)) {
|
if (a.piority>=0 && a.does_intersect(test)) {
|
||||||
can_claim=false;
|
can_claim=false;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ public class BlockEntitySignMixin {
|
||||||
area.enabled = true;
|
area.enabled = true;
|
||||||
ObjectPermList.get_default_perms(area.perms);
|
ObjectPermList.get_default_perms(area.perms);
|
||||||
area.setCorners(ca, cb);
|
area.setCorners(ca, cb);
|
||||||
area.name = "self_claim_sign_" + ownerId.replace(":", "_") + ".json";
|
area.name = "self_claim_sign_"+c+"_" + ownerId.replace(":", "_") + ".json";
|
||||||
area.zoneId = zone.zoneId;
|
area.zoneId = zone.zoneId;
|
||||||
|
|
||||||
PlayerAreaPerm plr_perm = PlayerAreaPerm.get_owner_perm(ownerId);
|
PlayerAreaPerm plr_perm = PlayerAreaPerm.get_owner_perm(ownerId);
|
||||||
|
@ -84,13 +85,4 @@ public class BlockEntitySignMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInt(String str) {
|
|
||||||
try {
|
|
||||||
Integer.parseInt(str);
|
|
||||||
return true;
|
|
||||||
} catch(NumberFormatException e){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,13 @@ public class block_util {
|
||||||
return new BlockPosition(c,x,y,z);
|
return new BlockPosition(c,x,y,z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isInt(String str) {
|
||||||
|
try {
|
||||||
|
Integer.parseInt(str);
|
||||||
|
return true;
|
||||||
|
} catch(NumberFormatException e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue