bugfix in region setup, add anti mob spawn
All checks were successful
/ Auto-Build-App (push) Successful in 2m40s
All checks were successful
/ Auto-Build-App (push) Successful in 2m40s
This commit is contained in:
parent
b4cc649f81
commit
1767ab23f8
7 changed files with 54 additions and 4 deletions
|
@ -8,7 +8,7 @@ repositories {
|
|||
name "Cosmic Reach"
|
||||
url "https://github.com/CRModders/CosmicArchive/raw/main/versions"
|
||||
patternLayout {
|
||||
artifact "[classifier]/[revision]/client/Cosmic Reach-[revision].jar"
|
||||
artifact "[classifier]/[revision]/client/Cosmic-Reach-[revision].jar"
|
||||
}
|
||||
// This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory
|
||||
metadataSources {
|
||||
|
|
|
@ -9,9 +9,9 @@ group=net.pietru
|
|||
id=cookie_utils
|
||||
|
||||
# Dependency Versions
|
||||
cosmic_reach_version=0.3.2-pre10
|
||||
cosmic_reach_version=0.3.4
|
||||
# If unspecified, will use the version above
|
||||
cosmic_reach_server_version=0.3.2-pre10
|
||||
cosmic_reach_server_version=0.3.4
|
||||
cosmic_quilt_version=2.3.1
|
||||
#2.2.0
|
||||
|
||||
|
|
|
@ -70,6 +70,21 @@ public class Region {
|
|||
return can;
|
||||
}
|
||||
|
||||
public static boolean can_enter_position(Vector3 position,String action){
|
||||
boolean can = is_not_reloading;
|
||||
|
||||
if (is_not_reloading)
|
||||
for (int i = 0; i< areas.size; i++){
|
||||
Area a = areas.get(i);
|
||||
if (a.enabled && a.does_intersect(position)){
|
||||
can=a.get_action_bool(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return can;
|
||||
}
|
||||
|
||||
public static boolean is_area_user_type(Vector3 position,String player_id,String type){
|
||||
boolean can = false;
|
||||
|
||||
|
@ -144,6 +159,7 @@ public class Region {
|
|||
|
||||
perms.set_bool_perm("explode", region.getBoolean("explode", false));
|
||||
perms.set_bool_perm("enter", region.getBoolean("enter", true));
|
||||
perms.set_bool_perm("enter", region.getBoolean("spawn_mob", true));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package net.pietru.cookie_utils.mixins;
|
||||
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import finalforeach.cosmicreach.entities.MobSpawner;
|
||||
import finalforeach.cosmicreach.world.Zone;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static net.pietru.cookie_utils.api.Region.can_enter_position;
|
||||
|
||||
@Mixin(MobSpawner.class)
|
||||
public class MobSpawnerMixin {
|
||||
|
||||
@Shadow
|
||||
int numberOfMobs;
|
||||
@Shadow
|
||||
private final Vector3 tmpSpawnPackLoc = new Vector3();
|
||||
|
||||
@Inject(method = "spawnMob", at = @At("HEAD"), cancellable = true)
|
||||
private void event_spawnMob(CallbackInfo ci, @Local Zone zone){
|
||||
if (!can_enter_position(tmpSpawnPackLoc,"spawn_mob")) {
|
||||
++numberOfMobs;
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ public class ObjectPermList {
|
|||
|
||||
val.addChild("explode", new JsonValue(false));
|
||||
val.addChild("enter", new JsonValue(true));
|
||||
val.addChild("spawn_mob", new JsonValue(true));
|
||||
}
|
||||
|
||||
public static void get_default_perms(ObjectPermList val){
|
||||
|
@ -45,5 +46,6 @@ public class ObjectPermList {
|
|||
|
||||
val.set_bool_perm("explode", false);
|
||||
val.set_bool_perm("enter", true);
|
||||
val.set_bool_perm("spawn_mob", true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class regionSetup extends Setup {
|
|||
area.setCorners(p1,p2);
|
||||
if (!name.endsWith(".json"))
|
||||
name+=".json";
|
||||
area.name=name;
|
||||
run_setup_finish();
|
||||
});
|
||||
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
"BlockBreakMixin",
|
||||
"BlockPlaceMixin",
|
||||
"InteractBlockMixin",
|
||||
"MessagePacketMixin",
|
||||
"LoginPacketMixin",
|
||||
"MessagePacketMixin",
|
||||
"MobSpawnerMixin",
|
||||
"PlayerPositionMixin",
|
||||
"ServerSingletonsMixin"
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue