generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 修复陷阱箱的同步问题 2. 灵魂出窍支持容器预览 3. 多人游戏空潜影盒堆叠修复 4. 多人游戏蜜蜂数量预览
- Loading branch information
Showing
11 changed files
with
155 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
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
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
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/plusls/MasaGadget/mixin/server/block/MixinBeehiveBlockEntity.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,25 @@ | ||
package io.github.plusls.MasaGadget.mixin.server.block; | ||
|
||
import net.minecraft.block.entity.BeehiveBlockEntity; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; | ||
import net.minecraft.util.Tickable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(BeehiveBlockEntity.class) | ||
public abstract class MixinBeehiveBlockEntity extends BlockEntity implements Tickable { | ||
|
||
@Shadow | ||
public abstract CompoundTag toTag(CompoundTag tag); | ||
|
||
public MixinBeehiveBlockEntity() { | ||
super(null); | ||
} | ||
|
||
@Override | ||
public BlockEntityUpdateS2CPacket toUpdatePacket() { | ||
return new BlockEntityUpdateS2CPacket(this.pos, 0, this.toTag(new CompoundTag())); | ||
} | ||
} |
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
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
47 changes: 47 additions & 0 deletions
47
src/main/java/io/github/plusls/MasaGadget/mixin/server/item/MixinItemStack.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,47 @@ | ||
package io.github.plusls.MasaGadget.mixin.server.item; | ||
|
||
import io.github.plusls.MasaGadget.MasaGadgetMod; | ||
import net.minecraft.block.ShulkerBoxBlock; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.ListTag; | ||
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; | ||
|
||
@Mixin(ItemStack.class) | ||
public abstract class MixinItemStack { | ||
@Shadow | ||
public abstract Item getItem(); | ||
|
||
@Inject(method = "getMaxCount", at = @At("HEAD"), cancellable = true) | ||
public void getMaxStackSizeStackSensitive(CallbackInfoReturnable<Integer> ci) { | ||
// support shulkerbox stack | ||
Item item = this.getItem(); | ||
// MasaGadgetMod.LOGGER.info("ItemStack: {}", this); | ||
if (this.getItem() instanceof BlockItem && | ||
((BlockItem) item).getBlock() instanceof ShulkerBoxBlock && | ||
!shulkerBoxHasItems((ItemStack) (Object) this)) { | ||
//MasaGadgetMod.LOGGER.info("Modify ret!"); | ||
ci.setReturnValue(64); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
private static boolean shulkerBoxHasItems(ItemStack stackShulkerBox) { | ||
// MasaGadgetMod.LOGGER.info("Try to calc shulkerBoxHasItems: {}", stackShulkerBox); | ||
CompoundTag nbt = stackShulkerBox.getTag(); | ||
if (nbt != null && nbt.contains("BlockEntityTag", 10)) { | ||
CompoundTag tag = nbt.getCompound("BlockEntityTag"); | ||
if (tag.contains("Items", 9)) { | ||
ListTag tagList = tag.getList("Items", 10); | ||
return tagList.size() > 0; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
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
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