User Tools

Site Tools


tutorial:containers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:containers [2020/04/02 11:04] – [Block and BlockItem] Replace BlockWithEntity with BlockEntityProvider and other cleanup earthcomputertutorial:containers [2020/04/02 12:57] – [Block and BlockItem] Revert BlockWithEntity change earthcomputer
Line 6: Line 6:
  
 <code java [enable_line_numbers="true"] BiggerChestBlock.java> <code java [enable_line_numbers="true"] BiggerChestBlock.java>
-public class BiggerChestBlock extends Block implements BlockEntityProvider {+public class BiggerChestBlock extends BlockWithEntity {
     public BiggerChestBlock(Settings settings) {     public BiggerChestBlock(Settings settings) {
         super(settings);         super(settings);
 +    }
 +    
 +    // A side effect of extending BlockWithEntity is it changes the render type to INVISIBLE, so we have to revert this
 +    @Override
 +    public BlockRenderType getRenderType(BlockState state) {
 +        return BlockRenderType.MODEL;
     }     }
  
Line 191: Line 197:
  
     // Shift + Player Inv Slot     // Shift + Player Inv Slot
 +    @Override
     public ItemStack transferSlot(PlayerEntity player, int invSlot) {     public ItemStack transferSlot(PlayerEntity player, int invSlot) {
         ItemStack newStack = ItemStack.EMPTY;         ItemStack newStack = ItemStack.EMPTY;
Line 252: Line 259:
     public static final String BIGGER_CHEST_TRANSLATION_KEY = Util.createTranslationKey("container", BIGGER_CHEST);     public static final String BIGGER_CHEST_TRANSLATION_KEY = Util.createTranslationKey("container", BIGGER_CHEST);
  
 +    @Override
     public void onInitialize() {     public void onInitialize() {
         [...]         [...]
Line 263: Line 271:
  
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 +    @Override
     public void onInitializeClient() {     public void onInitializeClient() {
         [...]         [...]
tutorial/containers.txt · Last modified: 2022/05/27 15:57 by solidblock