Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hopefully fixed getIsBlock syncing issue #14

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public ShieldMixin(World world) {
super(world);
}

@Unique
private static final int DATA_BLOCKING = 23;

// shadows allow us to access variables in a class we are mixing to.
@Shadow
public InventoryPlayer inventory;
Expand Down Expand Up @@ -72,8 +75,11 @@ public ShieldMixin(World world) {
@Unique
private int fireTicks;

@Unique
private boolean isBlock;
@Inject(method = "init", at = @At("TAIL"))
public void defineSynchedData(CallbackInfo ci) {
entityData.define(DATA_BLOCKING, (byte)0);
}


@Override
public void shieldmod$Parry(int parryTicks) {
Expand All @@ -97,11 +103,11 @@ public ShieldMixin(World world) {

@Override
public boolean shieldmod$getIsBlock() {
return isBlock;
return entityData.getByte(DATA_BLOCKING) != 0;
}
@Override
public void shieldmod$setIsBlock(boolean bool) {
this.isBlock = bool;
this.entityData.set(DATA_BLOCKING, bool ? (byte)1 : (byte)0);
}
@Override
public int shieldmod$getCounterTicks(){
Expand Down Expand Up @@ -341,15 +347,15 @@ public void tickMixin(CallbackInfo ci){
if (stack.getItem() instanceof ShieldItem) {

ShieldItem shield = ((ShieldItem) stack.getItem());
if (isBlock && (shield.tool == ShieldMaterials.TOOL_LEATHER || shield.tool == ShieldMaterials.TOOL_WOOD)) {
if (shieldmod$getIsBlock() && (shield.tool == ShieldMaterials.TOOL_LEATHER || shield.tool == ShieldMaterials.TOOL_WOOD)) {
this.xd *= 0.65D;
this.zd *= 0.65D;
}
else if (isBlock && shield.tool == ShieldMaterials.TOOL_DIAMOND){
else if (shieldmod$getIsBlock() && shield.tool == ShieldMaterials.TOOL_DIAMOND){
this.xd *= 0.20D;
this.zd *= 0.20D;
}
else if (isBlock){
else if (shieldmod$getIsBlock()){
this.xd *= 0.4D;
this.zd *= 0.4D;
}
Expand Down
85 changes: 0 additions & 85 deletions src/main/java/mizurin/shieldmod/mixins/SynchedEntityMixin.java

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/shieldmod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"FieldMixin",
"KnockBackMixin",
"ShieldMixin",
"SynchedEntityMixin",
"WorldFeatureLabyrinthMixin",
"WorldMixin"
],
Expand Down
Loading