Skip to content

Commit

Permalink
Merge pull request #5 from topi-banana/master
Browse files Browse the repository at this point in the history
Update 1.2.1.
GG~
  • Loading branch information
topi-banana authored Mar 24, 2024
2 parents 9054333 + ddf9225 commit e3a5cda
Show file tree
Hide file tree
Showing 43 changed files with 1,766 additions and 88 deletions.
82 changes: 79 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ Enable /view command to changes the simulation distance of the server without op
- Allowed options: `true`, `false`, `ops`, `0`, `1`, `2`, `3`, `4`
- Categories: `SURVIVAL`, `COMMAND`, `TAICHI`

### commandHat
Allows you to equip items to your head slot using /hat.
Ported from EssentialAddons.
- Type: `String`
- Default value: `ops`
- Allowed options: `true`, `false`, `ops`, `0`, `1`, `2`, `3`, `4`
- Categories: `SURVIVAL`, `COMMAND`, `TAICHI`

### commandSit
Player can sit down when using /sit.
Ported from PCA.
- Type: `String`
- Default value: `ops`
- Allowed options: `true`, `false`, `ops`, `0`, `1`, `2`, `3`, `4`
- Categories: `SURVIVAL`, `COMMAND`, `TAICHI`

### commandNotice
Enable /notice command to change notice logger value.
- Type: `String`
Expand All @@ -50,14 +66,67 @@ Ported from chronos carpet.
- Default value: `false`
- Categories: `OPTIMIZATION`, `TAICHI`

### blockEntitySyncing
Enable sync of blockEntity on the server without op.
effective radius of blockEntitySyncing.
### blockInventorySyncing
Enable sync of blockInventory on the server without op
(0: disable, -1: infinity)
- Type: `boolean`
- Default value: `false`
- Categories: `SURVIVAL`, `PROTOCOL`, `TAICHI`

### optimizedHypot
Changes MathHelper.hypot to a faster implementation. It gives nearly perfectly accurate results
Currently only effect chunks blending so will likely be unnoticeable. It is ~1.6x faster
recommended that you set this on permanently, and restart the server for best results
- Type: `boolean`
- Default value: `false`
- Categories: `OPTIMIZATION`, `TAICHI`

### optimizedRounding
Changes Math.round to a faster implementation. Although it does not give the exact same results
This does not affect many things and will most likely be unnoticeable. It is ~1.28x faster
- Type: `boolean`
- Default value: `false`
- Categories: `OPTIMIZATION`, `TAICHI`

### optimizedFurnaces
This mod does a few things relating to the vanilla furnace, blast furnace, and smoker so that they run faster during their update method, improving TPS.
- Type: `boolean`
- Default value: `false`
- Categories: `OPTIMIZATION`, `TAICHI`

### defaultOpLevel
set OP-permission when join to server
- Type: `int`
- Default value: `0`
- Categories: `CREATIVE`, `TAICHI`

### deathNoticeDiscord
Death notification to discord chat over webhook.
(value type is URI)
- Type: `String`
- Default value: `#None`
- Categories: `SURVIVAL`, `TAICHI`

### deathNoticeDiscordType
deathNoticeDiscord Message Type
(embed or text)
- Type: `boolean`
- Default value: `embed`
- Categories: `SURVIVAL`, `TAICHI`

### serverName
set ServerName for deathNoticeDiscord
- Type: `boolean`
- Default value: `#None`
- Categories: `SURVIVAL`, `TAICHI`

## taichiPacketRateLimit
Set packet rate limit TaichiCarpet-Protocol
- Type: `int`
- Default value: `-1`
- Categories: `PROTOCOL`, `TAICHI`


## commands

### view
Expand All @@ -75,6 +144,13 @@ effective radius of blockEntitySyncing.

`[<distance>]` : must be between `0` to `32`

### hat
`/hat` : ...


### sit
`/sit` : ...

### notice
`/notice <text>` : change notice logger text

Expand Down
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ repositories {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
maven {
name 'JitPack'
url 'https://jitpack.io'
}
}

dependencies {
Expand All @@ -23,7 +27,10 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "maven.modrinth:carpet:${project.carpet_version}"
modImplementation "maven.modrinth:essentialclient:${project.essentialclient_version}"
//modImplementation "maven.modrinth:essentialclient:${project.essentialclient_version}"

include "com.github.Fallen-Breath:conditional-mixin:${project.conditionalmixin_version}"
modImplementation "com.github.Fallen-Breath:conditional-mixin:${project.conditionalmixin_version}"
}

processResources {
Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ yarn_mappings=1.20.1+build.10
loader_version=0.15.3

# Mod Properties
mod_version = 1.1.3
mod_version = 1.1.5
maven_group = org.taichiServer
archives_base_name = taichi-carpet

# Dependencies
fabric_version=0.91.0+1.20.1

carpet_version=1.4.112
essentialclient_version=1.20.1-1.4.2
#essentialclient_version=1.20.1-1.4.2

# https://github.com/Fallen-Breath/conditional-mixin
conditionalmixin_version = v0.5.1
62 changes: 62 additions & 0 deletions src/main/java/PCA/mixin/rule/playerSit/MixinArmorStandEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package PCA.mixin.rule.playerSit;

import PCA.util.rule.playerSit.SitEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
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;

@Mixin(ArmorStandEntity.class)
public abstract class MixinArmorStandEntity extends LivingEntity implements SitEntity {
private boolean sitEntity = false;

protected MixinArmorStandEntity(EntityType<? extends LivingEntity> entityType, World world) {
super(entityType, world);
}

@Shadow
protected abstract void setMarker(boolean marker);

@Override
public boolean isSitEntity() {
return sitEntity;
}

@Override
public void setSitEntity(boolean isSitEntity) {
this.sitEntity = isSitEntity;
this.setMarker(isSitEntity);
this.setInvisible(isSitEntity);
}

@Override
protected void removePassenger(Entity passenger) {
if (this.isSitEntity()) {
this.setPosition(this.getX(), this.getY() + 0.16, this.getZ());
this.kill();
}
super.removePassenger(passenger);
}

@Inject(method = "writeCustomDataToNbt", at = @At(value = "RETURN"))
private void postWriteCustomDataToNbt(NbtCompound nbt, CallbackInfo ci) {
if (this.sitEntity) {
nbt.putBoolean("SitEntity", true);
}
}

@Inject(method = "readCustomDataFromNbt", at = @At(value = "RETURN"))
private void postReadCustomDataFromNbt(NbtCompound nbt, CallbackInfo ci) {
if (nbt.contains("SitEntity", NbtElement.BYTE_TYPE)) {
this.sitEntity = nbt.getBoolean("SitEntity");
}
}
}
7 changes: 7 additions & 0 deletions src/main/java/PCA/util/rule/playerSit/SitEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package PCA.util.rule.playerSit;

public interface SitEntity {
boolean isSitEntity();

void setSitEntity(boolean sitEntity);
}
57 changes: 57 additions & 0 deletions src/main/java/carpetfixes/helpers/FastMath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package carpetfixes.helpers;

public class FastMath {

private static final double HYPOT_MAX_MAG = 2^511;
private static final double HYPOT_FACTOR = 2^750;

/**
* @author FX - PR0CESS
* ~1.25x faster than {@link Math#round(float)}
*/
public static int round(float a) {
return a > 0F ? (int)(a + .5F) : (int)(a - .5F);
}

/**
* @author FX - PR0CESS
* ~1.28x faster than {@link Math#round(double)}
*/
public static long round(double a) {
return a > 0D ? (long)(a + .5D) : (long)(a - .5D);
}

/**
* @author FX - PR0CESS
* Hypot implementation from the jafama library. Not 100% accurate! (3E-14%, 15 is perfectly accurate)
* ~1.6x faster than {@link Math#hypot(double,double)}
*/
public static double hypot(double x, double y) {
x = Math.abs(x);
y = Math.abs(y);
if (y < x) { // Ensuring x <= y
final double a = x;
x = y;
y = a;
} else if (!(y >= x)) { // Testing if we have some NaN
return x == Double.POSITIVE_INFINITY ? Double.POSITIVE_INFINITY : Double.NaN;
}
if (y-x == y) { // x too small to subtract from y
return y;
} else {
double factor;
if (y > HYPOT_MAX_MAG) { // y is too large: scaling down
x *= (1/HYPOT_FACTOR);
y *= (1/HYPOT_FACTOR);
factor = HYPOT_FACTOR;
} else if (x < (1/HYPOT_MAX_MAG)) { // x is too small: scaling up
x *= HYPOT_FACTOR;
y *= HYPOT_FACTOR;
factor = (1/HYPOT_FACTOR);
} else {
factor = 1.0;
}
return factor * Math.sqrt(x*x+y*y);
}
}
}
Loading

0 comments on commit e3a5cda

Please sign in to comment.