-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement missed bukkit things (#1625)
* implement missed bukkit things * migrate to Decorate * fix crash * bring #1586
- Loading branch information
1 parent
4e387fc
commit a842e85
Showing
3 changed files
with
82 additions
and
0 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
45 changes: 45 additions & 0 deletions
45
.../io/izzel/arclight/common/mixin/core/world/level/block/entity/BannerBlockEntityMixin.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,45 @@ | ||
package io.izzel.arclight.common.mixin.core.world.level.block.entity; | ||
|
||
import io.izzel.arclight.mixin.Decorate; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.component.DataComponents; | ||
import net.minecraft.world.level.block.entity.BannerBlockEntity; | ||
import net.minecraft.world.level.block.entity.BannerPatternLayers; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(BannerBlockEntity.class) | ||
public abstract class BannerBlockEntityMixin extends BlockEntity { | ||
|
||
@Shadow private BannerPatternLayers patterns; | ||
|
||
public BannerBlockEntityMixin(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) { | ||
super(blockEntityType, blockPos, blockState); | ||
} | ||
|
||
@Decorate(method = "method_58121", inject = true, at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/entity/BannerBlockEntity;patterns:Lnet/minecraft/world/level/block/entity/BannerPatternLayers;", opcode = Opcodes.PUTFIELD)) | ||
private void arclight$setPatterns(BannerPatternLayers layers) { | ||
this.setPatterns(layers); | ||
} | ||
|
||
@Decorate(method = "applyImplicitComponents", inject = true, at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/entity/BannerBlockEntity;patterns:Lnet/minecraft/world/level/block/entity/BannerPatternLayers;", opcode = Opcodes.PUTFIELD)) | ||
private void arclight$applyLimits(BlockEntity.DataComponentInput dataComponentInput) { | ||
this.setPatterns((BannerPatternLayers) dataComponentInput.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits | ||
} | ||
|
||
// CraftBukkit start | ||
public void setPatterns(BannerPatternLayers bannerpatternlayers) { | ||
if (bannerpatternlayers.layers().size() > 20) { | ||
bannerpatternlayers = new BannerPatternLayers(List.copyOf(bannerpatternlayers.layers().subList(0, 20))); | ||
} | ||
this.patterns = bannerpatternlayers; | ||
} | ||
// CraftBukkit end | ||
} |
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