-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c581325
commit 72f37ec
Showing
1 changed file
with
16 additions
and
16 deletions.
There are no files selected for viewing
32 changes: 16 additions & 16 deletions
32
src/main/java/net/zepalesque/zenith/core/tile/ZenithHangingSignBlockEntity.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,33 +1,33 @@ | ||
package net.zepalesque.zenith.core.tile; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.level.block.entity.HangingSignBlockEntity; | ||
import net.minecraft.world.level.block.entity.SignBlockEntity; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.zepalesque.zenith.api.blockset.type.AbstractWoodSet; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class ZenithHangingSignBlockEntity extends SignBlockEntity { | ||
private static final int MAX_TEXT_LINE_WIDTH = 60; | ||
private static final int TEXT_LINE_HEIGHT = 9; | ||
public class ZenithHangingSignBlockEntity extends HangingSignBlockEntity { | ||
protected final AbstractWoodSet woodset; | ||
|
||
public ZenithHangingSignBlockEntity(BlockPos pos, BlockState state, Supplier<BlockEntityType<? extends ZenithHangingSignBlockEntity>> type) { | ||
super(type.get(), pos, state); | ||
protected <T extends AbstractWoodSet> ZenithHangingSignBlockEntity(BlockPos pos, BlockState state, T woodset) { | ||
super(pos, state); | ||
this.woodset = woodset; | ||
} | ||
|
||
public int getTextLineHeight() { | ||
return TEXT_LINE_HEIGHT; | ||
// Fix to get around crashing caused by the validateBlockState method | ||
public static <T extends AbstractWoodSet> ZenithHangingSignBlockEntity create(BlockPos pos, BlockState state, T set) { | ||
return new ZenithHangingSignBlockEntity(pos, state, set) { | ||
@Override | ||
public BlockEntityType<? extends ZenithHangingSignBlockEntity> getType() { | ||
return this.woodset == null ? set.hangingSignEntity().get() : this.woodset.hangingSignEntity().get(); | ||
} | ||
}; | ||
} | ||
|
||
public int getMaxTextLineWidth() { | ||
return MAX_TEXT_LINE_WIDTH; | ||
} | ||
|
||
public SoundEvent getSignInteractionFailedSoundEvent() { | ||
return SoundEvents.WAXED_HANGING_SIGN_INTERACT_FAIL; | ||
@Override | ||
public BlockEntityType<? extends ZenithHangingSignBlockEntity> getType() { | ||
return this.woodset.hangingSignEntity().get(); | ||
} | ||
} |