-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just implement ArmedArmorStandsModule with a mixin. Fixes #4470
- Loading branch information
Showing
3 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
29 changes: 9 additions & 20 deletions
29
src/main/java/org/violetmoon/quark/content/tweaks/module/ArmedArmorStandsModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,31 @@ | ||
package org.violetmoon.quark.content.tweaks.module; | ||
|
||
import org.violetmoon.zeta.event.bus.PlayEvent; | ||
import org.violetmoon.zeta.event.play.entity.ZEntityConstruct; | ||
import org.violetmoon.zeta.event.bus.LoadEvent; | ||
import org.violetmoon.zeta.event.load.ZConfigChanged; | ||
import org.violetmoon.zeta.module.ZetaLoadModule; | ||
import org.violetmoon.zeta.module.ZetaModule; | ||
import org.violetmoon.zeta.util.Hint; | ||
|
||
import net.minecraft.world.entity.decoration.ArmorStand; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.Items; | ||
|
||
/** | ||
* @author WireSegal | ||
* Created at 8:40 AM on 8/27/19. | ||
* | ||
* modified by quat | ||
* @see org.violetmoon.quark.mixin.ArmorStandMixin | ||
*/ | ||
@ZetaLoadModule(category = "tweaks") | ||
public class ArmedArmorStandsModule extends ZetaModule { | ||
|
||
@Hint Item armor_stand = Items.ARMOR_STAND; | ||
|
||
@PlayEvent | ||
public void entityConstruct(ZEntityConstruct event) { | ||
if(event.getEntity() instanceof ArmorStand stand) { | ||
if(!stand.isShowArms()) | ||
setShowArms(stand, true); | ||
} | ||
} | ||
public static boolean staticEnabled = true; | ||
|
||
private void setShowArms(ArmorStand e, boolean showArms) { | ||
e.getEntityData().set(ArmorStand.DATA_CLIENT_FLAGS, setBit(e.getEntityData().get(ArmorStand.DATA_CLIENT_FLAGS), 4, showArms)); | ||
@LoadEvent | ||
public void configChange(ZConfigChanged e) { | ||
staticEnabled = enabled; | ||
} | ||
|
||
private byte setBit(byte status, int bitFlag, boolean value) { | ||
if (value) | ||
status = (byte)(status | bitFlag); | ||
else | ||
status = (byte)(status & ~bitFlag); | ||
|
||
return status; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/violetmoon/quark/mixin/ArmorStandMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.violetmoon.quark.mixin; | ||
|
||
import net.minecraft.network.syncher.SynchedEntityData; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.decoration.ArmorStand; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.violetmoon.quark.content.tweaks.module.ArmedArmorStandsModule; | ||
|
||
@Mixin(ArmorStand.class) | ||
public class ArmorStandMixin { | ||
@ModifyConstant(method = "defineSynchedData", constant = @Constant(intValue = 0)) | ||
private int asdasld(int orig) { | ||
if(!ArmedArmorStandsModule.staticEnabled) | ||
return orig; | ||
|
||
//try to be careful - this is a kinda scary looking mixin, lol | ||
SynchedEntityData data = ((Entity) (Object) this).getEntityData(); | ||
if(data.hasItem(ArmorStand.DATA_CLIENT_FLAGS)) | ||
return orig; //it's already been defined | ||
|
||
else | ||
return orig | ArmorStand.CLIENT_FLAG_SHOW_ARMS; // | 4 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters