Skip to content

Commit

Permalink
Deactivate lamps upon being dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Mar 8, 2024
1 parent 3331f41 commit 3b7d199
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions common/src/main/java/miyucomics/hexical/mixin/ItemEntityMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package miyucomics.hexical.mixin;

import miyucomics.hexical.registry.HexicalItems;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack;
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(ItemEntity.class)
public abstract class ItemEntityMixin {
@Shadow public abstract ItemStack getStack();

@Inject(method = "tick", at = @At("HEAD"))
void deactivateLamp(CallbackInfo ci) {
if (this.getStack().getItem() == HexicalItems.INSTANCE.getARCH_LAMP_ITEM() && this.getStack().getNbt() != null)
this.getStack().getNbt().putBoolean("active", false);
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/hexical-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"CastingContextMixin",
"CastingHarnessMixin",
"ItemAbacusMixin",
"ItemEntityMixin",
"PlayerEntityMixin",
"WanderingTraderEntityMixin"
],
Expand Down

0 comments on commit 3b7d199

Please sign in to comment.