Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
at master 38 lines 1.6 kB view raw
1package net.lerariemann.infinity.item; 2 3import net.lerariemann.infinity.block.entity.ChromaticBlockEntity; 4import net.lerariemann.infinity.registry.core.ModComponentTypes; 5import net.lerariemann.infinity.registry.core.ModItems; 6import net.lerariemann.infinity.util.VersionMethods; 7import net.minecraft.core.BlockPos; 8import net.minecraft.world.InteractionHand; 9import net.minecraft.world.entity.player.Player; 10import net.minecraft.world.item.BlockItem; 11import net.minecraft.world.item.ItemStack; 12import net.minecraft.world.level.Level; 13import net.minecraft.world.level.block.Block; 14import net.minecraft.world.level.block.state.BlockState; 15import org.jetbrains.annotations.Nullable; 16 17public class ChromaticBlockItem extends BlockItem implements PortalDataHolder { 18 public ChromaticBlockItem(Block block, Properties settings) { 19 super(block, settings); 20 } 21 22 //todo: implement this properly 23 @Override 24 protected boolean updateCustomBlockEntityTag(BlockPos pos, Level world, @Nullable Player player, ItemStack stack, BlockState state) { 25 boolean bl = updateCustomBlockEntityTag(world, player, pos, stack); 26 if (player != null && player.getItemInHand(InteractionHand.OFF_HAND) 27 .is(ModItems.CHROMATIC_MATTER.get()) 28 && world.getBlockEntity(pos) instanceof ChromaticBlockEntity cbe) { 29 cbe.setColor(VersionMethods.getOrDefaultInt(stack, ModComponentTypes.COLOR, 0xFFFFFF)); 30 } 31 return bl; 32 } 33 34 @Override 35 public ItemStack getStack() { 36 return getDefaultInstance(); 37 } 38}