Skip to content

Commit

Permalink
Merge pull request #10 from topi-banana/master
Browse files Browse the repository at this point in the history
  • Loading branch information
topi-banana authored Apr 19, 2024
2 parents 8a79179 + ed22756 commit 6ffb439
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 46 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ A carpet extension made for [taichi SMP](https://discord.gg/6U6Y8c7HQ2). This in

## Rules

### disableWanderingOnVehicle
- Type: `boolean`
- Default value: `false`
- Categories: `OPTIMIZATION`, `TAICHI`

### disableWanderingOutOfWorld
- Type: `boolean`
- Default value: `false`
- Categories: `OPTIMIZATION`, `TAICHI`

### disablePushEntityOutOfWorld
- Type: `boolean`
- Default value: `false`
- Categories: `OPTIMIZATION`, `TAICHI`

### optimizedDragonRespawn
Optimize dragon respawn method. Ported from carpet AMS addition.
> [!WARNING]
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ yarn_mappings=1.20.1+build.10
loader_version=0.15.7

# Mod Properties
mod_version = 1.2.3
mod_version = 1.2.4
maven_group = org.taichiServer
archives_base_name = taichi-carpet

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/taichiCarpet/TaichiCarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ public class TaichiCarpetSettings
@Rule(
categories = { OPTIMIZATION, TAICHI }
)
public static boolean disableWanderingOnCart = false;
public static boolean disableWanderingOnVehicle = false;

@Rule(
categories = { OPTIMIZATION, TAICHI }
)
public static boolean disableWanderingOutOfWorld = false;

@Rule(
categories = { OPTIMIZATION, TAICHI }
)
public static boolean disablePushEntityOutOfWorld = false;

@Rule(
categories = { OPTIMIZATION, TAICHI }
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/taichiCarpet/commands/noticeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
}

public static int changeNoticeText(String text){

if(text.equals("#None")) {
notice.NOTICETEXT = null;
} else {
notice.NOTICETEXT = text;

}
return 1;
}
}
4 changes: 1 addition & 3 deletions src/main/java/taichiCarpet/logging/HUD/notice.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;

import java.util.Objects;

public class notice extends abstractHUDLogger{

public static final String NAME = "notice";
Expand All @@ -27,7 +25,7 @@ public static notice getInstance() {

@Override
public Text[] onHudUpdate(String option, PlayerEntity playerEntity) {
if (Objects.equals(NOTICETEXT, "reset") || notice.NOTICETEXT == null){
if (notice.NOTICETEXT == null){
return null;
} else {
return new Text[]{
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/taichiCarpet/mixins/WanderAroundGoalAccessor.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package taichiCarpet.mixins.disablePushFromAway;

import net.minecraft.entity.Entity;
import net.minecraft.registry.RegistryKey;
import net.minecraft.world.World;
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 taichiCarpet.TaichiCarpetSettings;

@Mixin(Entity.class)
public class EntityMixin {
@Shadow
private World world;

@Inject(method = "pushAwayFrom(Lnet/minecraft/entity/Entity;)V", at = @At("HEAD"), cancellable = true)
public void pushAwayFrom(Entity entity, CallbackInfo callbackInfo) {
if(TaichiCarpetSettings.disablePushEntityOutOfWorld) {
RegistryKey<World> dim = world.getRegistryKey();
if(dim.equals(World.OVERWORLD)){
if( entity.prevY > 319 || entity.prevY < -64 ){
callbackInfo.cancel();
return;
}
} else if (dim.equals(World.NETHER)){
if( entity.prevY > 255 || entity.prevY < 0 ){
callbackInfo.cancel();
return;
}
} else if (dim.equals(World.END)){
if( entity.prevY > 255 || entity.prevY < 0 ){
callbackInfo.cancel();
return;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package taichiCarpet.mixins.disableWandering;

import net.minecraft.entity.ai.pathing.EntityNavigation;
import net.minecraft.entity.ai.pathing.Path;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.registry.RegistryKey;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
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.CallbackInfoReturnable;
import taichiCarpet.TaichiCarpetSettings;

@Mixin(EntityNavigation.class)
public class EntityNavigationMixin {

@Final
@Shadow
protected MobEntity entity;

@Final
@Shadow
protected World world;

@Inject(method = "startMovingAlong(Lnet/minecraft/entity/ai/pathing/Path;D)Z", at = @At("HEAD"), cancellable = true)
private void startMovingAlong(@Nullable Path path, double speed, CallbackInfoReturnable<Boolean> cir){

if(TaichiCarpetSettings.disableWanderingOnVehicle){
if(entity.getVehicle() != null){
cir.setReturnValue(false);
return;
}
}

if(TaichiCarpetSettings.disableWanderingOutOfWorld) {
RegistryKey<World> dim = world.getRegistryKey();
if(dim.equals(World.OVERWORLD)){
if( entity.prevY > 319 || entity.prevY < -64 ){
cir.setReturnValue(false);
return;
}
} else if (dim.equals(World.NETHER)){
if( entity.prevY > 255 || entity.prevY < 0 ){
cir.setReturnValue(false);
return;
}
} else if (dim.equals(World.END)){
if( entity.prevY > 255 || entity.prevY < 0 ){
cir.setReturnValue(false);
return;
}
}
}
}
}
24 changes: 0 additions & 24 deletions src/main/java/taichiCarpet/mixins/disableWanderingOnCartMixin.java

This file was deleted.

6 changes: 5 additions & 1 deletion src/main/resources/assets/taichiCarpet/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

"carpet.rule.optimizedDragonRespawn.desc" : "optimized dragon respawn, developing",

"carpet.rule.disableWanderingOnCart.desc" : "entity on minecart should not do wandering pathfinding",
"carpet.rule.disableWanderingOnVehicle.desc" : "entity on vehicle should not do wandering pathfinding",

"carpet.rule.disableWanderingOutOfWorld.desc" : "entity out of world should not do wandering pathfinding",

"carpet.rule.disablePushEntityOutOfWorld.desc" : ";;",

"carpet.rule.disableNetherPortalCollisionCheck.desc": "Disable laggy nether portal collision checks introduced in 1.19.3",
"carpet.rule.disableNetherPortalCollisionCheck.extra0": "Large mobs may suffocate when going through portals if you enable this",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/taichi.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"package": "taichiCarpet.mixins",
"compatibilityLevel": "JAVA_17",
"mixins": [
"disableWanderingOnCartMixin",
"EntityCollisionMixin",
"HUDControllerMixin",
"PlayerCommandMixin",
"ServerPlayerEntityMixin",
"WanderAroundGoalAccessor"
"disablePushFromAway.EntityMixin",
"disableWandering.EntityNavigationMixin"
],
"client": [
],
Expand Down

0 comments on commit 6ffb439

Please sign in to comment.