Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.

ugh

+598 -168
+1 -1
build.fabric.gradle.kts
··· 186 186 } 187 187 replacements.string { 188 188 direction = eval(current.version, ">1.21.4") 189 - replace("DimensionTransition", "TeleportTransition") 189 + replace("DimensionTransition ", "TeleportTransition ") 190 190 } 191 191 replacements.string { 192 192 direction = eval(current.version, ">1.21.4")
+1 -1
build.forge.gradle.kts
··· 209 209 } 210 210 replacements.string { 211 211 direction = eval(current.version, ">1.21.4") 212 - replace("DimensionTransition", "TeleportTransition") 212 + replace("DimensionTransition ", "TeleportTransition ") 213 213 } 214 214 replacements.string { 215 215 direction = eval(current.version, ">1.21.4")
+1 -1
build.neoforge.gradle.kts
··· 143 143 } 144 144 replacements.string { 145 145 direction = eval(current.version, ">1.21.4") 146 - replace("DimensionTransition", "TeleportTransition") 146 + replace("DimensionTransition ", "TeleportTransition ") 147 147 } 148 148 replacements.string { 149 149 direction = eval(current.version, ">1.21.4")
+3 -2
src/main/java/net/lerariemann/infinity/access/Timebombable.java
··· 1 1 package net.lerariemann.infinity.access; 2 2 3 3 import net.lerariemann.infinity.util.InfinityMethods; 4 + import net.lerariemann.infinity.util.VersionMethods; 4 5 import net.lerariemann.infinity.util.core.RandomProvider; 5 6 import net.lerariemann.infinity.util.teleport.WarpLogic; 6 7 import net.minecraft.core.Holder; ··· 34 35 } 35 36 else if (i > 200) { 36 37 if (i%4 == 0) { 37 - Registry<DamageType> r = player.serverLevel().getServer().registryAccess().lookupOrThrow(Registries.DAMAGE_TYPE); 38 - Holder<DamageType> entry = r.wrapAsHolder(r.get(InfinityMethods.getId("world_ceased"))); 38 + Registry<DamageType> r = player.level().getServer().registryAccess().lookupOrThrow(Registries.DAMAGE_TYPE); 39 + Holder<DamageType> entry = r.wrapAsHolder(VersionMethods.getFromRegistry(r, InfinityMethods.getId("world_ceased"))); 39 40 player.hurt(new DamageSource(entry), i > 400 ? 2.0f : 1.0f); 40 41 } 41 42 }
+8 -2
src/main/java/net/lerariemann/infinity/block/custom/AltarBlock.java
··· 107 107 //?} else { 108 108 /*BlockGetter 109 109 *///?} 110 - world, BlockPos pos, BlockState state) { 111 - ItemStack res = super.getCloneItemStack(world, pos, state); 110 + world, BlockPos pos, BlockState state 111 + //? if >1.21.2 112 + , boolean bl 113 + ) { 114 + ItemStack res = super.getCloneItemStack(world, pos, state 115 + //? if >1.21.2 116 + , bl 117 + ); 112 118 //? if >1.21 { 113 119 res.applyComponentsAndValidate(toComponentChanges(state)); 114 120 //?} else {
+2 -2
src/main/java/net/lerariemann/infinity/block/custom/AntBlock.java
··· 71 71 String s = VersionMethods.getNameAsString(BuiltInRegistries.BLOCK, down); 72 72 var state = down.defaultBlockState(); 73 73 if (PlatformMethods.isInBlack(state)) { 74 - return toWhite ? BuiltInRegistries.BLOCK.get(VersionMethods.id(s.replace("black", "white"))) : down; 74 + return toWhite ? VersionMethods.getFromRegistry(BuiltInRegistries.BLOCK, VersionMethods.id(s.replace("black", "white"))) : down; 75 75 } 76 76 if (PlatformMethods.isInWhite(state)) { 77 - return toWhite ? down : BuiltInRegistries.BLOCK.get(VersionMethods.id(s.replace("white", "black"))); 77 + return toWhite ? down : VersionMethods.getFromRegistry(BuiltInRegistries.BLOCK, VersionMethods.id(s.replace("white", "black"))); 78 78 } 79 79 return null; 80 80 }
+14 -4
src/main/java/net/lerariemann/infinity/block/custom/BiomeBottleBlock.java
··· 100 100 @Nullable 101 101 @Override 102 102 public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level world, BlockState state, BlockEntityType<T> type) { 103 - return world.isClientSide ? null : createTickerHelper(type, ModBlockEntities.BIOME_BOTTLE.get(), BiomeBottleBlockEntity::serverTick); 103 + return world.isClientSide() ? null : createTickerHelper(type, ModBlockEntities.BIOME_BOTTLE.get(), BiomeBottleBlockEntity::serverTick); 104 104 } 105 105 106 106 ··· 111 111 //?} else { 112 112 /*BlockGetter world 113 113 *///?} 114 - , BlockPos pos, BlockState state) { 114 + , BlockPos pos, BlockState state 115 + //? if >1.21.2 116 + , boolean bl 117 + ) { 115 118 return world.getBlockEntity(pos) instanceof BiomeBottleBlockEntity bbbe 116 119 ? bbbe.asStack() 117 - : super.getCloneItemStack(world, pos, state); 120 + : super.getCloneItemStack(world, pos, state 121 + //? if >1.21.2 122 + , bl 123 + ); 118 124 } 119 125 120 126 public static final int maxAllowedCharge = 10000; ··· 238 244 } 239 245 return registryEntry2; 240 246 }, world.getChunkSource().randomState().sampler()); 241 - chunk.setUnsaved(true); 247 + //? if >1.21.2 { 248 + chunk.markUnsaved(); 249 + //?} else { 250 + /*chunk.setUnsaved(true); 251 + *///?} 242 252 } 243 253 }); 244 254 world.getChunkSource().chunkMap.resendBiomesForChunks(set.stream().toList());
+23 -10
src/main/java/net/lerariemann/infinity/block/custom/ChromaticBlock.java
··· 4 4 import net.lerariemann.infinity.block.entity.ChromaticBlockEntity; 5 5 import net.minecraft.core.BlockPos; 6 6 import net.minecraft.core.Direction; 7 + import net.minecraft.util.RandomSource; 7 8 import net.minecraft.world.InteractionHand; 8 9 import net.minecraft.world.InteractionResult; 9 10 import net.minecraft.world.entity.player.Player; 10 11 import net.minecraft.world.item.ItemStack; 11 - import net.minecraft.world.level.BlockGetter; 12 - import net.minecraft.world.level.Level; 13 - import net.minecraft.world.level.LevelAccessor; 14 - import net.minecraft.world.level.LevelReader; 12 + import net.minecraft.world.level.*; 15 13 import net.minecraft.world.level.block.BaseEntityBlock; 16 14 import net.minecraft.world.level.block.Block; 17 15 import net.minecraft.world.level.block.Blocks; ··· 43 41 //?} else { 44 42 /*BlockGetter 45 43 *///?} 46 - world, BlockPos pos, BlockState state) { 47 - ItemStack res = super.getCloneItemStack(world, pos, state); 44 + world, BlockPos pos, BlockState state 45 + //? if >1.21.2 { 46 + , boolean bl 47 + //?} 48 + ) { 49 + ItemStack res = super.getCloneItemStack(world, pos, state 50 + //? if >1.21.2 { 51 + , true 52 + //?} 53 + ); 48 54 if (!res.isEmpty() && world.getBlockEntity(pos) instanceof ChromaticBlockEntity cbe) { 49 55 //? if >1.21 { 50 56 res.applyComponents(cbe.asMap()); ··· 97 103 //?} else { 98 104 /*public 99 105 *///?} 100 - BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { 101 - return !state.canSurvive(world, pos) 102 - ? Blocks.AIR.defaultBlockState() 103 - : super.updateShape(state, direction, neighborState, world, pos, neighborPos); 106 + //? if >1.21.2 { 107 + BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess scheduledTickAccess, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { 108 + //?} else { 109 + /*BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { 110 + *///?} 111 + if (!state.canSurvive(world, pos)) return Blocks.AIR.defaultBlockState(); 112 + //? if >1.21.2 { 113 + return super.updateShape(state, world, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); 114 + //?} else { 115 + /*return super.updateShape(state, direction, neighborState, world, pos, neighborPos); 116 + *///?} 104 117 } 105 118 106 119 @Override
+19 -6
src/main/java/net/lerariemann/infinity/block/custom/InfinityPortalBlock.java
··· 29 29 import net.minecraft.world.*; 30 30 import net.minecraft.world.entity.Entity; 31 31 import net.minecraft.world.entity.EntitySpawnReason; 32 + import net.minecraft.world.entity.InsideBlockEffectApplier; 32 33 import net.minecraft.world.entity.item.ItemEntity; 33 34 import net.minecraft.world.entity.player.Player; 34 35 import net.minecraft.world.item.Item; ··· 168 169 int colorInt = npbe.getPortalColor(); 169 170 Vec3 vec3d = Vec3.fromRGB24(colorInt); 170 171 double color = 1.0D + (colorInt >> 16 & 0xFF) / 255.0D; 171 - eff = new DustParticleOptions(new Vector3f((float)vec3d.x, (float)vec3d.y, (float)vec3d.z), (float)color); 172 + eff = new DustParticleOptions( 173 + //? if <1.21.2 { 174 + /*new Vector3f((float)vec3d.x, (float)vec3d.y, (float)vec3d.z), (float)color 175 + *///?} else { 176 + colorInt, 1 177 + //?} 178 + ); 172 179 } 173 180 174 181 world.addParticle(eff, d, e, f, g, h, j); ··· 179 186 * Adds logic for portal-based recipes. 180 187 */ 181 188 @Override 182 - public void entityInside(BlockState state, Level w, BlockPos pos, Entity entity) { 189 + public void entityInside(BlockState state, Level w, BlockPos pos, Entity entity 190 + //? if >1.21.2 { 191 + ,InsideBlockEffectApplier insideBlockEffectApplier, boolean bl2 192 + //?} 193 + ) { 183 194 AtomicBoolean bl = new AtomicBoolean(false); 184 195 if (w instanceof ServerLevel world 185 196 && world.getBlockEntity(pos) instanceof InfinityPortalBlockEntity ipbe) { ··· 219 230 } 220 231 } 221 232 } 222 - if (!bl.get()) super.entityInside(state, w, pos, entity); 233 + if (!bl.get()) super.entityInside(state, w, pos, entity 234 + //? if >1.21.2 { 235 + ,insideBlockEffectApplier, bl2 236 + //?} 237 + ); 223 238 } 224 239 /** 225 240 * Spawns chaos pawns in the portal. ··· 254 269 public 255 270 //? if >1.21.2 { 256 271 TeleportTransition 257 - //?} else if >1.21 { 258 - /*TeleportTransition 259 - *///?} else { 272 + //?} else { 260 273 /*PortalInfo 261 274 *///?} 262 275 getPortalDestination(ServerLevel worldFrom, Entity entity, BlockPos posFrom) {
+14 -9
src/main/java/net/lerariemann/infinity/block/custom/IridescentBlock.java
··· 8 8 import net.minecraft.core.Direction; 9 9 import net.minecraft.sounds.SoundEvents; 10 10 import net.minecraft.sounds.SoundSource; 11 + import net.minecraft.util.RandomSource; 11 12 import net.minecraft.world.InteractionHand; 12 13 import net.minecraft.world.InteractionResult; 13 14 import net.minecraft.world.entity.player.Player; 14 - import net.minecraft.world.level.BlockGetter; 15 - import net.minecraft.world.level.Level; 16 - import net.minecraft.world.level.LevelAccessor; 17 - import net.minecraft.world.level.LevelReader; 15 + import net.minecraft.world.level.*; 18 16 import net.minecraft.world.level.block.Block; 19 17 import net.minecraft.world.level.block.Blocks; 20 18 import net.minecraft.world.level.block.state.BlockState; ··· 100 98 protected 101 99 //?} else { 102 100 /*public 103 - *///?} 104 - BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { 105 - return !state.canSurvive(world, pos) 106 - ? Blocks.AIR.defaultBlockState() 107 - : super.updateShape(state, direction, neighborState, world, pos, neighborPos); 101 + *///?} 102 + //? if >1.21.2 { 103 + BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess scheduledTickAccess, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { 104 + //?} else { 105 + /*BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { 106 + *///?} 107 + if (!state.canSurvive(world, pos)) return Blocks.AIR.defaultBlockState(); 108 + //? if >1.21.2 { 109 + return super.updateShape(state, world, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); 110 + //?} else { 111 + /*return super.updateShape(state, direction, neighborState, world, pos, neighborPos); 112 + *///?} 108 113 } 109 114 110 115 @Override
+9 -2
src/main/java/net/lerariemann/infinity/block/custom/TimeBombBlock.java
··· 10 10 import net.minecraft.MethodsReturnNonnullByDefault; 11 11 import net.minecraft.core.BlockPos; 12 12 import net.minecraft.core.particles.ParticleTypes; 13 + //? if >1.21.2 { 14 + import net.minecraft.core.particles.PowerParticleOption; 15 + //?} 13 16 import net.minecraft.network.chat.Component; 14 17 import net.minecraft.server.level.ServerLevel; 15 18 import net.minecraft.server.level.ServerPlayer; ··· 83 86 84 87 static AreaEffectCloud genCloud(Level world, BlockPos pos) { 85 88 AreaEffectCloud e = new AreaEffectCloud(world, pos.getCenter().x(), pos.getCenter().y(), pos.getCenter().z()); 86 - e.setParticle(ParticleTypes.DRAGON_BREATH); 89 + //? if >1.21.2 { 90 + e.setCustomParticle(PowerParticleOption.create(ParticleTypes.DRAGON_BREATH, 1)); 91 + //?} else { 92 + /*e.setParticle(ParticleTypes.DRAGON_BREATH); 93 + *///?} 87 94 e.setRadius(1.0f); 88 95 e.setDuration(3500); 89 96 e.setRadiusPerTick(0.006f); ··· 121 128 } 122 129 else if (world instanceof ServerLevel) { 123 130 world.playSound(null, pos, ModSounds.portalFail, SoundSource.BLOCKS, 1f, 1f); 124 - player.sendSystemMessage(Component.translatable("error.infinity.timebomb.fail")); 131 + player.displayClientMessage(Component.translatable("error.infinity.timebomb.fail"), false); 125 132 } 126 133 } 127 134 else {
+34 -8
src/main/java/net/lerariemann/infinity/block/entity/ChromaticBlockEntity.java
··· 176 176 177 177 @Override 178 178 //? if >1.21 { 179 - public void loadAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) { 180 - super.loadAdditional(nbt, registryLookup); 181 - //?} else { 182 - /*public void load(CompoundTag nbt) { 183 - super.load(nbt); 184 - *///?} 185 - if (nbt.getTagType("color") == Tag.TAG_INT) 179 + public void loadAdditional( 180 + //? if >1.21.2 { 181 + ValueInput nbt 182 + //?} else { 183 + /*CompoundTag tag 184 + *///?} 185 + //? if =1.21.1 186 + /*,HolderLookup.Provider registryLookup*/ 187 + ) { 188 + super.loadAdditional(nbt 189 + //? if =1.21.1 190 + /*, registryLookup*/ 191 + ); 192 + //? if >1.21.2 { 193 + if (nbt.contains("color")) { 194 + nbt.getInt("color").ifPresent(this::setColor); 195 + } 196 + if (nbt.contains("h")) { 197 + hue = (short) nbt.getShortOr("h", hue); 198 + saturation = (short) nbt.getShortOr("s", saturation); 199 + brightness = (short) nbt.getShortOr("b", brightness); 200 + updateColor(); 201 + } 202 + //?} else { 203 + /*if (nbt.getTagType("color") == Tag.TAG_INT) 186 204 setColor(nbt.getInt("color")); 187 205 else if (nbt.getTagType("color") == Tag.TAG_COMPOUND) { 188 206 CompoundTag color = NbtUtils.getCompound(nbt, "color"); ··· 191 209 brightness = NbtUtils.getShort(color, "b"); 192 210 updateColor(); 193 211 } 212 + *///?} 194 213 } 195 214 @Override 196 215 protected void saveAdditional( ··· 206 225 //? if =1.21.1 207 226 /*, registryLookup*/ 208 227 ); 209 - CompoundTag color = new CompoundTag(); 228 + //? if >1.21.2 { 229 + nbt.putShort("h", hue); 230 + nbt.putShort("s", saturation); 231 + nbt.putShort("b", brightness); 232 + //?} else { 233 + /*CompoundTag color = new CompoundTag(); 210 234 color.putShort("h", hue); 211 235 color.putShort("s", saturation); 212 236 color.putShort("b", brightness); 213 237 nbt.put("color", color); 238 + *///?} 239 + 214 240 } 215 241 216 242 public int getTint() {
+14 -2
src/main/java/net/lerariemann/infinity/block/entity/CosmicAltarBlockEntity.java
··· 8 8 import net.minecraft.world.level.Level; 9 9 import net.minecraft.world.level.block.entity.BlockEntity; 10 10 import net.minecraft.world.level.block.state.BlockState; 11 + import net.minecraft.world.level.storage.ValueInput; 11 12 import net.minecraft.world.level.storage.ValueOutput; 12 13 import org.jetbrains.annotations.Nullable; 13 14 ··· 30 31 31 32 //? if >1.21 { 32 33 @Override 33 - public void loadAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) { 34 - super.loadAdditional(nbt, registryLookup); 34 + public void loadAdditional( 35 + //? if >1.21.2 { 36 + ValueInput nbt 37 + //?} else { 38 + /*CompoundTag tag 39 + *///?} 40 + //? if =1.21.1 41 + /*,HolderLookup.Provider registryLookup*/ 42 + ) { 43 + super.loadAdditional(nbt 44 + //? if =1.21.1 45 + /*, registryLookup*/ 46 + ); 35 47 } 36 48 //?} else { 37 49 /*@Override
+41 -15
src/main/java/net/lerariemann/infinity/block/entity/InfinityPortalBlockEntity.java
··· 19 19 import net.minecraft.server.level.ServerLevel; 20 20 import net.minecraft.world.inventory.ContainerData; 21 21 import net.minecraft.world.level.block.state.BlockState; 22 + import net.minecraft.world.level.storage.ValueInput; 23 + import net.minecraft.world.level.storage.ValueOutput; 22 24 import org.jetbrains.annotations.Nullable; 23 25 24 26 //? if neoforge ··· 147 149 148 150 149 151 @Override 150 - public void saveAdditional(CompoundTag tag 151 - //? if >1.21 152 - ,HolderLookup.Provider registryLookup 152 + public void saveAdditional( 153 + //? if >1.21.2 { 154 + ValueOutput tag 155 + //?} else { 156 + /*CompoundTag tag 157 + *///?} 158 + //? if =1.21.1 159 + /*,HolderLookup.Provider registryLookup*/ 153 160 ) { 154 161 super.saveAdditional(tag 155 - //? if >1.21 156 - , registryLookup 162 + //? if =1.21.1 163 + /*, registryLookup*/ 157 164 ); 158 165 tag.putInt("Color", this.portalColor); 159 166 tag.putString("Dimension", this.dimension.toString()); 160 167 tag.putBoolean("Open", this.isOpen); 161 168 if (otherSidePos != null) { 162 - CompoundTag pos = new CompoundTag(); 169 + //? if >1.21.2 { 170 + tag.store("other_side", BlockPos.CODEC, otherSidePos); 171 + //?} else { 172 + /*CompoundTag pos = new CompoundTag(); 163 173 pos.putInt("x", otherSidePos.getX()); 164 174 pos.putInt("y", otherSidePos.getY()); 165 175 pos.putInt("z", otherSidePos.getZ()); 166 176 tag.put("other_side", pos); 177 + *///?} 167 178 } 168 179 } 169 180 170 181 @Override 171 182 //? if >1.21 { 172 - public void loadAdditional(CompoundTag tag, HolderLookup.Provider registryLookup) { 173 - super.loadAdditional(tag, registryLookup); 174 - //?} else { 175 - /*public void load(CompoundTag tag) { 176 - super.load(tag); 177 - *///?} 178 - if (tag.getTagType("Dimension") == Tag.TAG_ANY_NUMERIC) { //conversion from legacy formats 183 + public void loadAdditional( 184 + //? if >1.21.2 { 185 + ValueInput tag 186 + //?} else { 187 + /*CompoundTag tag 188 + *///?} 189 + //? if =1.21.1 190 + /*,HolderLookup.Provider registryLookup*/ 191 + ) { 192 + super.loadAdditional(tag 193 + //? if =1.21.1 194 + /*, registryLookup*/ 195 + ); 196 + //? if <1.21.2 { 197 + /*if (tag.getTagType("Dimension") == Tag.TAG_ANY_NUMERIC) { //conversion from legacy formats 179 198 this.portalColor = NbtUtils.getInt(tag, "Dimension") & 0xFFFFFF; 180 199 if (tag.contains("DimensionName")) { 181 200 this.dimension = VersionMethods.id(NbtUtils.getString(tag, "DimensionName")); 182 201 } 183 202 else this.dimension = InfinityMethods.getDimId(this.portalColor); 184 203 } 185 - else if (tag.getTagType("Dimension") == Tag.TAG_STRING) { //new better format 204 + else if (tag.getTagType("Dimension") == Tag.TAG_STRING) { //new better format 205 + *///?} else { 206 + if (tag.contains("Dimension")) { 207 + //?} 186 208 this.dimension = VersionMethods.id(NbtUtils.getString(tag, "Dimension")); 187 209 if (level != null && level.getServer() != null) 188 210 this.portalColor = NbtUtils.getInt(tag, "Color", PortalColorApplier.of(dimension, level.getServer()).apply(worldPosition) & 0xFFFFFF); ··· 194 216 } 195 217 this.isOpen = NbtUtils.getBoolean(tag, "Open", false); 196 218 if (tag.contains("other_side")) { 197 - CompoundTag pos = NbtUtils.getCompound(tag,"other_side"); 219 + //? if >1.21.2 { 220 + otherSidePos = tag.read("other_side", BlockPos.CODEC).get(); 221 + //?} else { 222 + /*CompoundTag pos = NbtUtils.getCompound(tag,"other_side"); 198 223 otherSidePos = new BlockPos(NbtUtils.getInt(pos, "x"), NbtUtils.getInt(pos, "y"), NbtUtils.getInt(pos, "z")); 224 + *///?} 199 225 } 200 226 } 201 227
+10
src/main/java/net/lerariemann/infinity/entity/client/AntEntityRenderState.java
··· 1 + package net.lerariemann.infinity.entity.client; 2 + 3 + import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; 4 + 5 + public class AntEntityRenderState extends LivingEntityRenderState { 6 + public int headYaw; 7 + public float limbAngle; 8 + public float limbDistance; 9 + public int headPitch; 10 + }
+33 -7
src/main/java/net/lerariemann/infinity/entity/client/AntModel.java
··· 17 17 import net.minecraft.util.Mth; 18 18 import org.jetbrains.annotations.NotNull; 19 19 20 - public class AntModel<T extends AntEntity> extends HierarchicalModel<T> { 20 + public class AntModel<T extends 21 + //? if >1.21.2 { 22 + AntEntityRenderState 23 + //?} else { 24 + /*AntEntity 25 + *///?} 26 + > extends 27 + //? if >1.21.2 { 28 + EntityModel 29 + //?} else { 30 + /*HierarchicalModel 31 + *///?} 32 + <T> { 21 33 public static final ModelLayerLocation MODEL_LAYER = 22 34 new ModelLayerLocation(InfinityMethods.getId("ant"), "main"); 23 35 ··· 31 43 private final ModelPart back_right_leg; 32 44 33 45 public AntModel(ModelPart root) { 34 - this.body = root.getChild("body"); 46 + //? if >1.21.2 47 + super(root); 48 + this.body = root.getChild("body"); 35 49 this.head = body.getChild("head"); 36 50 this.front_left_leg = body.getChild("front_left_leg"); 37 51 this.center_left_leg = body.getChild("center_left_leg"); ··· 81 95 return LayerDefinition.create(modelData, 64, 64); 82 96 } 83 97 84 - @Override 85 - //? if >1.21 { 98 + //? if =1.21.1 { 99 + /*@Override 86 100 public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, int color) { 87 101 body.render(matrices, vertices, light, overlay, color); 88 102 } 89 - //?} else { 103 + *///?} else if =1.20.1 { 90 104 /*public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { 91 105 super.renderToBuffer(poseStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); 92 106 } 93 107 *///?} 94 108 95 109 96 - @Override 110 + //? if <1.21.2 { 111 + /*@Override 97 112 public @NotNull ModelPart root() { 98 113 return body; 99 114 } 115 + *///?} 100 116 101 117 @Override 102 - public void setupAnim(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { 118 + public void setupAnim(T entity 119 + //? if <1.21.2 { 120 + /*, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch 121 + *///?} 122 + ) { 123 + //? if >1.21.2 { 124 + var headYaw = entity.headYaw; 125 + var headPitch = entity.headPitch; 126 + var limbAngle = entity.limbAngle; 127 + var limbDistance = entity.limbDistance; 128 + //?} 103 129 this.root().getAllParts().forEach(ModelPart::resetPose); 104 130 105 131 this.head.yRot = Mth.clamp(headYaw, -30.0F, 30.0F) * 0.017453292F;
+21 -2
src/main/java/net/lerariemann/infinity/entity/client/AntRenderer.java
··· 9 9 import net.minecraft.resources.ResourceLocation; 10 10 import org.jetbrains.annotations.NotNull; 11 11 12 - public class AntRenderer extends MobRenderer<AntEntity, AntModel<AntEntity>> { 12 + public class AntRenderer extends MobRenderer<AntEntity, 13 + //? if >1.21.2 { 14 + AntEntityRenderState, AntModel<AntEntityRenderState> 15 + //?} else { 16 + /*AntModel<AntEntity> 17 + *///?} 18 + > { 13 19 private static final ResourceLocation TEXTURE = InfinityMethods.getId("textures/entity/ant.png"); 14 20 15 21 public AntRenderer(EntityRendererProvider.Context context) { 16 22 super(context, new AntModel<>(context.bakeLayer(AntModel.MODEL_LAYER)), 0.6f); 17 23 } 18 24 25 + //? if >1.21.2 { 19 26 @Override 20 - public @NotNull ResourceLocation getTextureLocation(AntEntity entity) { 27 + public AntEntityRenderState createRenderState() { 28 + return new AntEntityRenderState(); 29 + } 30 + @Override 31 + public @NotNull ResourceLocation getTextureLocation(AntEntityRenderState entity) { 32 + return TEXTURE; 33 + } 34 + //?} else { 35 + /*@Override 36 + public ResourceLocation getTextureLocation(AntEntity renderState) { 21 37 return TEXTURE; 22 38 } 39 + *///?} 40 + 41 + 23 42 24 43 @Override 25 44 public void render(AntEntity mobEntity, float f, float g, PoseStack matrixStack,
+1 -1
src/main/java/net/lerariemann/infinity/entity/client/BishopModel.java
··· 17 17 BishopEntityRenderState 18 18 //?} else { 19 19 /*BishopEntity 20 - *///?} 20 + *///?} 21 21 > { 22 22 public static final ModelLayerLocation MODEL_LAYER = 23 23 new ModelLayerLocation(InfinityMethods.getId("bishop"), "main");
+10
src/main/java/net/lerariemann/infinity/entity/client/ChaosPawnRenderState.java
··· 1 + package net.lerariemann.infinity.entity.client; 2 + 3 + import net.minecraft.client.renderer.entity.state.HumanoidRenderState; 4 + import net.minecraft.nbt.CompoundTag; 5 + 6 + public class ChaosPawnRenderState extends HumanoidRenderState { 7 + public CompoundTag colors; 8 + public int id; 9 + public String customName; 10 + }
+25 -1
src/main/java/net/lerariemann/infinity/entity/client/ChaosPawnRenderer.java
··· 9 9 import net.minecraft.resources.ResourceLocation; 10 10 import org.jetbrains.annotations.NotNull; 11 11 12 - public class ChaosPawnRenderer extends HumanoidMobRenderer<ChaosPawn, HumanoidModel<ChaosPawn>> { 12 + public class ChaosPawnRenderer extends HumanoidMobRenderer<ChaosPawn, 13 + //? if >1.21.2 { 14 + ChaosPawnRenderState, 15 + //?} 16 + HumanoidModel< 17 + //? if >1.21.2 { 18 + ChaosPawnRenderState 19 + //?} else { 20 + /*ChaosPawn 21 + *///?} 22 + >> { 13 23 private static final ResourceLocation TEXTURE = InfinityMethods.getId("textures/entity/empty.png"); 14 24 public ChaosPawnRenderer(EntityRendererProvider.Context context) { 15 25 super(context, new HumanoidModel<>(context.bakeLayer(ModelLayers.PLAYER)), 0.25f); 16 26 this.addLayer(new ChaosPawnTint(this, new HumanoidModel<>(context.getModelSet().bakeLayer(ModelLayers.PLAYER)))); 17 27 } 28 + 29 + //? if >1.21.2 { 18 30 @Override 31 + public ChaosPawnRenderState createRenderState() { 32 + return new ChaosPawnRenderState(); 33 + } 34 + @Override 35 + public ResourceLocation getTextureLocation(ChaosPawnRenderState renderState) { 36 + return TEXTURE; 37 + } 38 + //?} else { 39 + 40 + /*@Override 19 41 public @NotNull ResourceLocation getTextureLocation(ChaosPawn e) { 20 42 return TEXTURE; 21 43 } 44 + *///?} 45 + 22 46 }
+83 -13
src/main/java/net/lerariemann/infinity/entity/client/ChaosPawnTint.java
··· 2 2 3 3 import net.lerariemann.infinity.entity.custom.ChaosPawn; 4 4 import net.lerariemann.infinity.entity.custom.TintableEntity; 5 + import net.lerariemann.infinity.util.InfinityMethods; 5 6 import net.lerariemann.infinity.util.VersionMethods; 6 - import net.minecraft.client.Minecraft; 7 + import net.lerariemann.infinity.util.core.NbtUtils; 7 8 import net.minecraft.client.model.HumanoidModel; 8 9 import net.minecraft.client.model.geom.ModelPart; 9 - import net.minecraft.client.renderer.MultiBufferSource; 10 10 import net.minecraft.client.renderer.RenderType; 11 + import net.minecraft.client.renderer.SubmitNodeCollector; 11 12 import net.minecraft.client.renderer.entity.LivingEntityRenderer; 12 13 import net.minecraft.client.renderer.entity.layers.RenderLayer; 13 - import net.minecraft.util.FastColor; 14 + import net.minecraft.client.renderer.feature.ModelFeatureRenderer; 15 + import net.minecraft.resources.ResourceLocation; 16 + //? if <1.21.2 { 17 + /*import net.minecraft.util.FastColor; 18 + *///?} 14 19 import com.mojang.blaze3d.vertex.PoseStack; 15 - import com.mojang.blaze3d.vertex.VertexConsumer; 20 + 16 21 import java.awt.Color; 17 22 18 - public class ChaosPawnTint extends RenderLayer<ChaosPawn, HumanoidModel<ChaosPawn>> { 19 - private final HumanoidModel<ChaosPawn> model; 20 - public ChaosPawnTint(ChaosPawnRenderer context, HumanoidModel<ChaosPawn> model) { 23 + public class ChaosPawnTint extends RenderLayer< 24 + //? if <1.21.2 { 25 + /*ChaosPawn, HumanoidModel<ChaosPawn> 26 + *///?} else { 27 + ChaosPawnRenderState, HumanoidModel<ChaosPawnRenderState> 28 + //?} 29 + > { 30 + private final HumanoidModel< 31 + //? if >1.21.2 { 32 + ChaosPawnRenderState 33 + //?} else { 34 + /*ChaosPawn 35 + *///?} 36 + > model; 37 + public ChaosPawnTint(ChaosPawnRenderer context, HumanoidModel< 38 + //? if >1.21.2 { 39 + ChaosPawnRenderState 40 + //?} else { 41 + /*ChaosPawn 42 + *///?} 43 + > model) { 21 44 super(context); 22 45 this.model = model; 23 46 } 24 47 25 - public void renderOneLayer(PoseStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, ChaosPawn livingEntity, ModelPart part, String name) { 48 + //? if >1.21.2 { 49 + public void renderOneLayer(PoseStack matrixStack, SubmitNodeCollector vertexConsumer, int light, int overlay, ChaosPawnRenderState livingEntity, ModelPart part, String name) { 26 50 int color; 27 - color = livingEntity.getColors().getInt(name); 51 + color = NbtUtils.getInt(livingEntity.colors, name); 52 + if (livingEntity.customName != null) { 53 + String s = livingEntity.customName; 54 + if ("jeb_".equals(s)) { 55 + color = TintableEntity.getColorJeb((int) (livingEntity.ageInTicks + (name.equals("hat") ? 200 : 0)), livingEntity.id); } 56 + if ("hue".equals(s)) { 57 + int n = (int) (livingEntity.ageInTicks + (name.equals("hat") ? 200 : 0) + livingEntity.id); 58 + float hue = n/400.f; 59 + hue = hue - (int)hue; 60 + color = Color.getHSBColor(hue, 1.0f, 1.0f).getRGB(); 61 + } 62 + } 63 + else { 64 + color = VersionMethods.opaque(color); 65 + } 66 + //fixme 1.21.10 this probably shouldn't be null 67 + vertexConsumer.submitModelPart(part, matrixStack, RenderType.cutout(), light, overlay, null, color, null); 68 + } 69 + //?} else { 70 + /*public void renderOneLayer(PoseStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, ChaosPawn livingEntity, ModelPart part, String name) { 71 + int color; 72 + color = NbtUtils.getInt(livingEntity.getColors(), name); 28 73 if (livingEntity.hasCustomName()) { 29 74 String s = livingEntity.getName().getString(); 30 - if ("jeb_".equals(s)) { 31 - color = TintableEntity.getColorJeb(livingEntity.tickCount + (name.equals("hat") ? 200 : 0), livingEntity.getId()); 75 + if ("jeb_".equals(s)) { 76 + color = TintableEntity.getColorJeb(livingEntity.tickCount + (name.equals("hat") ? 200 : 0), livingEntity.getId()); 32 77 } 33 78 if ("hue".equals(s)) { 34 79 int n = livingEntity.tickCount + (name.equals("hat") ? 200 : 0) + livingEntity.getId(); ··· 43 88 //? if >1.21 { 44 89 part.render(matrixStack, vertexConsumer, light, overlay, color); 45 90 //?} else { 46 - /*part.render(matrixStack, vertexConsumer, light, overlay, FastColor.ARGB32.red(color), FastColor.ARGB32.green(color), FastColor.ARGB32.blue(color), 1.0f); 47 - *///?} 91 + /^part.render(matrixStack, vertexConsumer, light, overlay, FastColor.ARGB32.red(color), FastColor.ARGB32.green(color), FastColor.ARGB32.blue(color), 1.0f); 92 + ^///?} 48 93 } 94 + *///?} 49 95 96 + //? if >1.21.2 { 50 97 @Override 98 + public void submit(PoseStack matrixStack, SubmitNodeCollector nodeCollector, int light, ChaosPawnRenderState state, float yRot, float xRot) { 99 + boolean bl = state.appearsGlowing() && state.isInvisible; 100 + if (state.isInvisible && !bl) { 101 + return; 102 + } 103 + ResourceLocation texture = InfinityMethods.getId("textures/entity/empty.png"); 104 + // VertexConsumer vertexConsumer = bl ? nodeCollector.getBuffer(RenderType.outline(texture)) : vertexConsumerProvider.getBuffer(RenderType.entityTranslucent(texture)); 105 + // TODO 1.21.3 these were probably necessary 106 + // (this.getContextModel()).copyStateTo(this.model); 107 + // this.model.animateModel(e, f, g, h); 108 + this.model.setupAnim(state); 109 + int o = LivingEntityRenderer.getOverlayCoords(state, 0.0f); 110 + renderOneLayer(matrixStack, nodeCollector, light, o, state, model.body, "body"); 111 + renderOneLayer(matrixStack, nodeCollector, light, o, state, model.head, "head"); 112 + renderOneLayer(matrixStack, nodeCollector, light, o, state, model.hat, "hat"); 113 + renderOneLayer(matrixStack, nodeCollector, light, o, state, model.leftArm, "left_arm"); 114 + renderOneLayer(matrixStack, nodeCollector, light, o, state, model.rightArm, "right_arm"); 115 + renderOneLayer(matrixStack, nodeCollector, light, o, state, model.leftLeg, "left_leg"); 116 + renderOneLayer(matrixStack, nodeCollector, light, o, state, model.rightLeg, "right_leg"); 117 + } 118 + //?} else { 119 + /*@Override 51 120 public void render(PoseStack matrixStack, MultiBufferSource vertexConsumerProvider, int i, ChaosPawn e, float f, float g, float h, float j, float k, float l) { 52 121 boolean bl = Minecraft.getInstance().shouldEntityAppearGlowing(e) && e.isInvisible(); 53 122 if (e.isInvisible() && !bl) { ··· 66 135 renderOneLayer(matrixStack, vertexConsumer, i, o, e, model.leftLeg, "left_leg"); 67 136 renderOneLayer(matrixStack, vertexConsumer, i, o, e, model.rightLeg, "right_leg"); 68 137 } 138 + *///?} 69 139 }
+6 -8
src/main/java/net/lerariemann/infinity/entity/client/DimensionalSlimeCoreRenderer.java
··· 1 1 package net.lerariemann.infinity.entity.client; 2 2 3 3 import com.mojang.blaze3d.vertex.PoseStack; 4 - import com.mojang.blaze3d.vertex.VertexConsumer; 5 4 //? if >1.21.2 { 6 5 import net.fabricmc.fabric.api.renderer.v1.render.FabricBlockModelRenderer; 7 6 import net.minecraft.client.renderer.SubmitNodeCollector; 8 7 //?} else { 9 8 /*import net.minecraft.client.renderer.MultiBufferSource; 10 9 *///?} 11 - import net.lerariemann.infinity.entity.custom.ChaosSlime; 12 - import net.minecraft.client.Minecraft; 13 10 import net.minecraft.client.model.SlimeModel; 14 - import net.minecraft.client.renderer.ItemBlockRenderTypes; 15 11 import net.minecraft.client.renderer.block.BlockRenderDispatcher; 16 12 import net.minecraft.client.renderer.entity.LivingEntityRenderer; 17 13 import net.minecraft.client.renderer.entity.RenderLayerParent; ··· 72 68 73 69 private void renderCore(PoseStack matrices, 74 70 //? if >1.21.2 { 75 - VertexConsumer 71 + SubmitNodeCollector 76 72 //?} else { 77 73 /*MultiBufferSource 78 74 *///?} 79 75 80 76 vertexConsumers, int light, BlockState coreState, int overlay) { 81 77 var coreModel = this.blockRenderManager.getBlockModel(coreState); 82 - //? if >1.21.2 { 83 - FabricBlockModelRenderer.render(matrices.last(), layer-> vertexConsumers, coreModel, 1.0f, 1.0f, 1.0f, light, overlay, null, BlockPos.ZERO, coreState); 84 - //?} else { 78 + //? if >1.21.9 { 79 + vertexConsumers.submitBlock(matrices, coreState, light, overlay, 0); 80 + //?} else if >1.21.8 { 81 + /*FabricBlockModelRenderer.render(matrices.last(), layer-> vertexConsumers, coreModel, 1.0f, 1.0f, 1.0f, light, overlay, null, BlockPos.ZERO, coreState); 82 + *///?} else { 85 83 /*this.blockRenderManager.getModelRenderer().renderModel(matrices.last(), vertexConsumers.getBuffer(ItemBlockRenderTypes.getChunkRenderType(coreState)), coreState, coreModel, 1.0f, 1.0f, 1.0f, light, overlay); 86 84 *///?} 87 85 }
+2
src/main/java/net/lerariemann/infinity/entity/client/TintedLayerRenderer.java
··· 10 10 import net.minecraft.client.renderer.entity.LivingEntityRenderer; 11 11 import net.minecraft.client.renderer.entity.RenderLayerParent; 12 12 import net.minecraft.client.renderer.entity.layers.RenderLayer; 13 + //? if <1.21.2 { 13 14 import net.minecraft.util.FastColor; 15 + //?} 14 16 import net.minecraft.world.entity.Mob; 15 17 16 18 public class TintedLayerRenderer<T extends Mob, S extends EntityModel<T>> extends RenderLayer<T, S> {
+12 -2
src/main/java/net/lerariemann/infinity/features/RandomColumnsFeature.java
··· 77 77 78 78 @Nullable 79 79 private static BlockPos moveDownToGround(LevelAccessor world, int seaLevel, BlockPos.MutableBlockPos mutablePos, int distance) { 80 - while (mutablePos.getY() > world.getMinBuildHeight() + 1 && distance > 0) { 80 + //? if <1.21.2 { 81 + /*var minY = world.getMinBuildHeight(); 82 + *///?} else { 83 + var minY = world.getMinY(); 84 + //?} 85 + while (mutablePos.getY() > minY + 1 && distance > 0) { 81 86 --distance; 82 87 if (RandomColumnsFeature.canPlaceAt(world, seaLevel, mutablePos)) { 83 88 return mutablePos; ··· 98 103 99 104 @Nullable 100 105 private static BlockPos moveUpToAir(LevelAccessor world, BlockPos.MutableBlockPos mutablePos, int distance) { 101 - while (mutablePos.getY() < world.getMaxBuildHeight() && distance > 0) { 106 + //? if <1.21.2 { 107 + /*var maxY = world.getMaxBuildHeight(); 108 + *///?} else { 109 + var maxY = world.getMaxY(); 110 + //?} 111 + while (mutablePos.getY() < maxY && distance > 0) { 102 112 --distance; 103 113 BlockState blockState = world.getBlockState(mutablePos); 104 114 if (CANNOT_REPLACE_BLOCKS.contains(blockState.getBlock())) {
+6 -1
src/main/java/net/lerariemann/infinity/features/RandomDungeonFeature.java
··· 77 77 blockPos2 = blockPos.offset(s, t, u); 78 78 BlockState blockState = structureWorldAccess.getBlockState(blockPos2); 79 79 if (s == k || t == -1 || u == p || s == l || t == 4 || u == q) { 80 - if (blockPos2.getY() >= structureWorldAccess.getMinBuildHeight() && !structureWorldAccess.getBlockState(blockPos2.below()).isSolid()) { 80 + //? if <1.21.2 { 81 + /*var minY = structureWorldAccess.getMinBuildHeight(); 82 + *///?} else { 83 + var minY = structureWorldAccess.getMinY(); 84 + //?} 85 + if (blockPos2.getY() >= minY && !structureWorldAccess.getBlockState(blockPos2.below()).isSolid()) { 81 86 structureWorldAccess.setBlock(blockPos2, AIR, Block.UPDATE_CLIENTS); 82 87 continue; 83 88 }
+4 -1
src/main/java/net/lerariemann/infinity/features/RandomFlatMushroomFeature.java
··· 24 24 boolean bl6 = bl3 || bl4; 25 25 if (bl5 && bl6) continue; 26 26 mutable.setWithOffset(start, j, y, k); 27 - if (world.getBlockState(mutable).isSolidRender(world, mutable)) continue; 27 + if (world.getBlockState(mutable).isSolidRender( 28 + //? if <1.21.2 29 + world, mutable 30 + )) continue; 28 31 BlockState blockState = config.capProvider().getState(random, start); 29 32 this.setBlock(world, mutable, blockState); 30 33 }
+12 -2
src/main/java/net/lerariemann/infinity/features/RandomMushroomFeature.java
··· 23 23 protected void generateStem(LevelAccessor world, RandomSource random, BlockPos pos, Config config, int height, BlockPos.MutableBlockPos mutablePos) { 24 24 for (int i = 0; i < height; ++i) { 25 25 mutablePos.set(pos).move(Direction.UP, i); 26 - if (world.getBlockState(mutablePos).isSolidRender(world, mutablePos)) continue; 26 + if (world.getBlockState(mutablePos).isSolidRender( 27 + //? if <1.21.2 28 + /*world, mutablePos*/ 29 + )) continue; 27 30 this.setBlock(world, mutablePos, config.stemProvider().getState(random, pos)); 28 31 } 29 32 } ··· 38 41 39 42 protected boolean canGenerate(LevelAccessor world, BlockPos pos, int height, BlockPos.MutableBlockPos mutablePos, Config config) { 40 43 int i = pos.getY(); 41 - if (i < world.getMinBuildHeight() + 1 || i + height + 1 >= world.getMaxBuildHeight()) { 44 + //? if <1.21.2 { 45 + /*var minY = world.getMinBuildHeight(); 46 + var maxY = world.getMaxBuildHeight(); 47 + *///?} else { 48 + var minY = world.getMinY(); 49 + var maxY = world.getMaxY(); 50 + //?} 51 + if (i < minY + 1 || i + height + 1 >= maxY) { 42 52 return false; 43 53 } 44 54 BlockState blockState = world.getBlockState(pos.below());
+4 -1
src/main/java/net/lerariemann/infinity/features/RandomRoundMushroomFeature.java
··· 25 25 boolean bl6 = bl3 || bl4; 26 26 if (i < y && bl5 == bl6) continue; 27 27 mutable.setWithOffset(start, l, i, m); 28 - if (world.getBlockState(mutable).isSolidRender(world, mutable)) continue; 28 + if (world.getBlockState(mutable).isSolidRender( 29 + //? if <1.21.2 30 + /*world, mutable*/ 31 + )) continue; 29 32 BlockState blockState = config.capProvider().getState(random, start); 30 33 this.setBlock(world, mutable, blockState); 31 34 }
+41 -17
src/main/java/net/lerariemann/infinity/iridescence/Iridescence.java
··· 29 29 import net.minecraft.server.level.ServerPlayer; 30 30 import net.minecraft.sounds.SoundEvents; 31 31 import net.minecraft.world.effect.MobEffectInstance; 32 - import net.minecraft.world.entity.EntityType; 33 - import net.minecraft.world.entity.LivingEntity; 34 - import net.minecraft.world.entity.Mob; 35 - import net.minecraft.world.entity.EntitySpawnReason; 32 + import net.minecraft.world.entity.*; 36 33 import net.minecraft.world.entity.ai.targeting.TargetingConditions; 37 34 import net.minecraft.world.entity.animal.AbstractFish; 38 35 import net.minecraft.world.entity.monster.Slime; ··· 46 43 import net.minecraft.world.level.block.Block; 47 44 import net.minecraft.world.level.material.FluidState; 48 45 import net.minecraft.world.phys.AABB; 46 + import net.minecraft.world.phys.Vec3; 49 47 import org.jetbrains.annotations.Nullable; 50 48 //? neoforge { 51 49 /*import net.neoforged.neoforge.event.EventHooks; ··· 108 106 DyeColor.PINK); 109 107 110 108 static Block getRandomColorBlock(LevelAccessor world, String str) { 111 - return BuiltInRegistries.BLOCK.get(VersionMethods.id(dyeColors.get(world.getRandom().nextInt(dyeColors.size())).getName() + "_" + str)); 109 + return VersionMethods.getFromRegistry(BuiltInRegistries.BLOCK, VersionMethods.id(dyeColors.get(world.getRandom().nextInt(dyeColors.size())).getName() + "_" + str)); 112 110 } 113 111 static Block getRandomColorBlock(double d, String str) { 114 - return BuiltInRegistries.BLOCK.get(VersionMethods.id(dyeColors.get((int)(d* dyeColors.size())).getName() + "_" + str)); 112 + return VersionMethods.getFromRegistry(BuiltInRegistries.BLOCK, VersionMethods.id(dyeColors.get((int)(d* dyeColors.size())).getName() + "_" + str)); 115 113 } 116 114 117 115 static int getAmplifierOnApply(LivingEntity entity, int original, boolean willingly) { ··· 195 193 } 196 194 197 195 static void loadShader(ServerPlayer player) { 198 - ModPayloads.sendShaderPayload(player, player.serverLevel(), true); 196 + ModPayloads.sendShaderPayload(player, player. 197 + //? if >1.21.2 { 198 + level() 199 + //?} else { 200 + /*serverLevel() 201 + *///?} 202 + , true); 199 203 } 200 204 static void unloadShader(ServerPlayer player) { 201 - ModPayloads.sendShaderPayload(player, player.serverLevel(), false); 205 + ModPayloads.sendShaderPayload(player, player. 206 + //? if >1.21.2 { 207 + level() 208 + //?} else { 209 + /*serverLevel() 210 + *///?} 211 + , false); 202 212 } 203 213 204 214 static boolean shouldApplyShader(@Nullable Player player) { ··· 230 240 compound.putDouble("x", player.position().x); 231 241 compound.putDouble("y", player.position().y); 232 242 compound.putDouble("z", player.position().z); 233 - compound.putString("dim", player.serverLevel().dimension().location().toString()); 243 + compound.putString("dim", player.level().dimension().location().toString()); 234 244 CommonIO.write(compound, InfinityMod.provider.savingPath, player.getStringUUID() + ".json"); 235 245 } 236 246 ··· 244 254 } 245 255 Path cookie = InfinityMod.provider.savingPath.resolve(player.getStringUUID() + ".json"); 246 256 CompoundTag comp = CommonIO.read(cookie); 247 - ServerLevel level = player.server.getLevel(ResourceKey.create(Registries.DIMENSION, VersionMethods.id(NbtUtils.getString(comp,"dim")))); 248 - if (level != null) 249 - player.teleportTo(level, comp.getDouble("x"), comp.getDouble("y"), comp.getDouble("z"), player.getYRot(), player.getXRot()); 257 + ServerLevel level = player.level().getServer().getLevel(ResourceKey.create(Registries.DIMENSION, VersionMethods.id(NbtUtils.getString(comp,"dim")))); 258 + if (level != null) { 259 + //? if >1.21.2 { 260 + VersionMethods.teleportTo(player, level, new Vec3(comp.getDoubleOr("x", 0), comp.getDoubleOr("y", 0), comp.getDoubleOr("z", 0)), player.getYRot(), player.getXRot()); 261 + //?} else { 262 + /*player.teleportTo(level, comp.getDouble("x"), comp.getDouble("y"), comp.getDouble("z"), player.getYRot(), player.getXRot()); 263 + *///?} 264 + } 250 265 else WarpLogic.respawnAlive(player); 251 266 try { 252 267 Files.deleteIfExists(cookie); ··· 255 270 } 256 271 257 272 static ResourceLocation getIdForWarp(ServerPlayer player) { 258 - ServerLevel w = player.serverLevel().getServer().overworld(); 273 + ServerLevel w = player.level().getServer().overworld(); 259 274 return InfinityMethods.getRandomId(new Random(w.getSeed() + w.getGameTime() / ticksInHour)); 260 275 } 261 276 ··· 285 300 if (!convertibles.containsKey(type)) return; 286 301 EntityType<? extends Mob> typeNew = convertibles.get(type).get(); 287 302 if (typeNew != null) { 288 - Mob newEntity = typeNew.create(currEntity.level()); 303 + Mob newEntity = typeNew.create(currEntity.level() 304 + //? if >1.21.2 305 + , EntitySpawnReason.CONVERSION 306 + ); 289 307 if (newEntity != null) { 290 308 currEntity.discard(); 291 309 ModEntities.copy(currEntity, newEntity); ··· 321 339 static void convTriggers(LivingEntity entity) { 322 340 triggerConversion(entity.level().getNearestPlayer(entity.getX(), entity.getY(), entity.getZ(), 323 341 50, false), entity); 324 - entity.level().getNearbyPlayers(TargetingConditions.DEFAULT, entity, AABB.ofSize(entity.position(), 10,10, 10)) 342 + //? if >1.21.2 { 343 + entity.level().getEntities(entity, AABB.ofSize(entity.position(), 10,10, 10)) 344 + .forEach(p -> triggerConversion(p, entity)); 345 + //?} else { 346 + /*entity.level().getNearbyPlayers(TargetingConditions.DEFAULT, entity, AABB.ofSize(entity.position(), 10,10, 10)) 325 347 .forEach(p -> triggerConversion(p, entity)); 348 + *///?} 349 + 326 350 } 327 351 328 - static void triggerConversion(Player player, LivingEntity entity) { 329 - if (player instanceof ServerPlayer np) { 352 + static void triggerConversion(Entity potentialPlayer, LivingEntity entity) { 353 + if (potentialPlayer instanceof ServerPlayer np) { 330 354 ModCriteria.CONVERT_MOB.get().trigger(np, entity); 331 355 } 332 356 }
+11 -2
src/main/java/net/lerariemann/infinity/iridescence/IridescenceLiquidBlock.java
··· 8 8 import net.minecraft.nbt.CompoundTag; 9 9 import net.minecraft.server.level.ServerLevel; 10 10 import net.minecraft.world.entity.Entity; 11 + import net.minecraft.world.entity.InsideBlockEffectApplier; 11 12 import net.minecraft.world.entity.LivingEntity; 12 13 import net.minecraft.world.entity.Mob; 13 14 import net.minecraft.world.entity.item.ItemEntity; ··· 25 26 } 26 27 27 28 @Override 28 - public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { 29 - super.entityInside(state, world, pos, entity); 29 + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity 30 + //? if >1.21.2 { 31 + , InsideBlockEffectApplier applier, boolean intersects 32 + //?} 33 + ) { 34 + super.entityInside(state, world, pos, entity 35 + //? if >1.21.2 { 36 + , applier, intersects 37 + //?} 38 + ); 30 39 if (world.getFluidState(pos).getAmount() > 3 && world instanceof ServerLevel w) 31 40 if (Objects.requireNonNull(entity) instanceof Player player) { 32 41 Iridescence.tryBeginJourney(player, RandomProvider.ruleInt("iridescenceContactLevel"), false);
+6 -1
src/main/java/net/lerariemann/infinity/iridescence/IridescentCooldownEffect.java
··· 2 2 3 3 import net.lerariemann.infinity.registry.core.ModStatusEffects; 4 4 import net.lerariemann.infinity.util.VersionMethods; 5 + import net.minecraft.server.level.ServerLevel; 5 6 import net.minecraft.world.effect.MobEffect; 6 7 import net.minecraft.world.effect.MobEffectCategory; 7 8 import net.minecraft.world.effect.MobEffectInstance; ··· 19 20 //?} else { 20 21 /*void 21 22 *///?} 22 - applyEffectTick(LivingEntity entity, int amplifier) { 23 + applyEffectTick( 24 + //? if >1.21.2 { 25 + ServerLevel serverLevel, 26 + //?} 27 + LivingEntity entity, int amplifier) { 23 28 int cooldownDuration = Iridescence.getCooldownDuration(); 24 29 if (cooldownDuration > 0) 25 30 entity.addEffect(new MobEffectInstance(VersionMethods.effectOrHolder(ModStatusEffects.IRIDESCENT_COOLDOWN),
+25 -10
src/main/java/net/lerariemann/infinity/item/BiomeBottleItem.java
··· 12 12 import net.minecraft.world.item.Item; 13 13 import net.minecraft.world.item.ItemStack; 14 14 import net.minecraft.world.item.TooltipFlag; 15 + //? if >1.21.2 { 16 + import net.minecraft.world.item.component.TooltipDisplay; 17 + //?} 15 18 import net.minecraft.world.level.Level; 16 19 import net.minecraft.world.level.block.Block; 17 20 import java.util.List; 21 + import java.util.function.Consumer; 18 22 19 23 public class BiomeBottleItem extends BlockItem { 20 24 public BiomeBottleItem(Block block, Properties settings) { ··· 23 27 24 28 @Override 25 29 public void appendHoverText(ItemStack stack, 26 - //? if >1.21 { 27 - TooltipContext 28 - //?} else { 29 - /*Level 30 - *///?} 31 - context, List<Component> tooltip, TooltipFlag type) { 32 - super.appendHoverText(stack, context, tooltip, type); 30 + //? if >1.21 { 31 + TooltipContext 32 + //?} else { 33 + /*Level 34 + *///?} 35 + context, 36 + //? if >1.21.2 { 37 + TooltipDisplay tooltipDisplay, Consumer<Component> tooltipAdder 38 + //?} else { 39 + /*List<Component> tooltip 40 + *///?} 41 + , TooltipFlag type) { 42 + //? if >1.21.2 { 43 + super.appendHoverText(stack, context, tooltipDisplay, tooltipAdder, type); 44 + //?} else { 45 + /*super.appendHoverText(stack, context, tooltip, type); 46 + Consumer<Component> tooltipAdder = tooltip::add; 47 + *///?} 33 48 ResourceLocation biome = VersionMethods.getBiomeComponents(stack); 34 49 if (biome != null) { 35 - tooltip.add(Component.translatable(Util.makeDescriptionId("biome", biome)).withStyle(ChatFormatting.GRAY)); 50 + tooltipAdder.accept(Component.translatable(Util.makeDescriptionId("biome", biome)).withStyle(ChatFormatting.GRAY)); 36 51 } 37 52 else { 38 53 MutableComponent mutableText = Component.translatable("caption.infinity.biomebottle.empty"); 39 - tooltip.add(mutableText.withStyle(ChatFormatting.GRAY)); 54 + tooltipAdder.accept(mutableText.withStyle(ChatFormatting.GRAY)); 40 55 } 41 56 if (type.isAdvanced()) { 42 - tooltip.add(Component.translatable("caption.infinity.biomebottle.charge", BiomeBottleBlock.getCharge(stack)).withStyle(ChatFormatting.GRAY)); 57 + tooltipAdder.accept(Component.translatable("caption.infinity.biomebottle.charge", BiomeBottleBlock.getCharge(stack)).withStyle(ChatFormatting.GRAY)); 43 58 } 44 59 } 45 60 }
+15 -14
src/main/java/net/lerariemann/infinity/item/F4Item.java
··· 75 75 public void appendHoverText(ItemStack stack, 76 76 //? if >1.21 { 77 77 TooltipContext 78 + //?} else { 79 + /*Level 80 + *///?} 81 + context, 82 + //? if >1.21.2 { 83 + TooltipDisplay tooltipDisplay, Consumer<Component> tooltipAdder 78 84 //?} else { 79 - /*Level 80 - *///?} 81 - context, 82 - //? if >1.21.4 { 83 - TooltipDisplay display, Consumer<Component> 84 - //?} else { 85 - /*List<Component> 86 - *///?} 87 - tooltip, TooltipFlag type) { 88 - super.appendHoverText(stack, context, 89 - //? if >1.21.4 { 90 - display, 91 - //?} 92 - tooltip, type); 85 + /*List<Component> tooltip 86 + *///?} 87 + , TooltipFlag type) { 88 + //? if >1.21.2 { 89 + super.appendHoverText(stack, context, tooltipDisplay, tooltipAdder, type); 90 + //?} else { 91 + /*super.appendHoverText(stack, context, tooltip, type); 92 + Consumer<Component> tooltipAdder = tooltip::add; 93 + *///?} 93 94 ResourceLocation dimension = VersionMethods.getDimensionIdentifier(stack); 94 95 MutableComponent mutableText = getDimensionTooltip(dimension).withStyle(ChatFormatting.GRAY); 95 96 //? if <1.21.2 {
+19 -5
src/main/java/net/lerariemann/infinity/item/TransfiniteKeyItem.java
··· 21 21 import net.minecraft.world.item.Item; 22 22 import net.minecraft.world.item.ItemStack; 23 23 import net.minecraft.world.item.TooltipFlag; 24 + import net.minecraft.world.item.component.TooltipDisplay; 24 25 import org.jetbrains.annotations.NotNull; 25 26 26 27 //? if neoforge { ··· 29 30 import java.util.List; 30 31 import java.util.Objects; 31 32 import java.util.Optional; 33 + import java.util.function.Consumer; 34 + 32 35 //? if neoforge { 33 36 /*@ParametersAreNonnullByDefault 34 37 *///?} ··· 92 95 public void appendHoverText(ItemStack stack, 93 96 //? if >1.21 { 94 97 TooltipContext 98 + //?} else { 99 + /*Level 100 + *///?} 101 + context, 102 + //? if >1.21.2 { 103 + TooltipDisplay tooltipDisplay, Consumer<Component> tooltipAdder 95 104 //?} else { 96 - /*Level 97 - *///?} 98 - context, List<Component> tooltip, TooltipFlag type) { 99 - super.appendHoverText(stack, context, tooltip, type); 105 + /*List<Component> tooltip 106 + *///?} 107 + , TooltipFlag type) { 108 + //? if >1.21.2 { 109 + super.appendHoverText(stack, context, tooltipDisplay, tooltipAdder, type); 110 + //?} else { 111 + /*super.appendHoverText(stack, context, tooltip, type); 112 + Consumer<Component> tooltipAdder = tooltip::add; 113 + *///?} 100 114 ResourceLocation dimension = VersionMethods.getDimensionIdentifier(stack); 101 115 MutableComponent mutableText = (dimension != null) 102 116 ? InfinityMethods.getDimensionNameAsText(dimension) 103 117 : Component.translatable("tooltip.infinity.key.randomise"); 104 - tooltip.add(mutableText.withStyle(ChatFormatting.GRAY)); 118 + tooltipAdder.accept(mutableText.withStyle(ChatFormatting.GRAY)); 105 119 } 106 120 }
+3 -1
src/main/java/net/lerariemann/infinity/item/function/ChromaCarpetRecipe.java
··· 100 100 return result.copyWithCount(3); 101 101 } 102 102 103 - @Override 103 + //? if <1.21.2 { 104 + /*@Override 104 105 public boolean canCraftInDimensions(int width, int height) { 105 106 return width >= 2 && height >= 1; 106 107 } 108 + *///?} 107 109 108 110 @Override 109 111 public RecipeSerializer<ChromaCarpetRecipe> getSerializer() {
+16 -5
src/main/java/net/lerariemann/infinity/item/function/ChromaticColoringRecipe.java
··· 1 1 package net.lerariemann.infinity.item.function; 2 2 3 - import com.google.gson.JsonObject; 4 3 import com.mojang.serialization.MapCodec; 5 4 import com.mojang.serialization.codecs.RecordCodecBuilder; 6 5 import net.lerariemann.infinity.registry.core.ModItemFunctions; 7 6 import net.lerariemann.infinity.registry.core.ModItems; 8 - import net.lerariemann.infinity.util.VersionMethods; 9 7 import net.minecraft.core.HolderLookup; 10 8 import net.minecraft.core.NonNullList; 11 9 //? if >1.21 { ··· 72 70 INSTANCE 73 71 } 74 72 @Override 75 - public @NotNull RecipeType<?> getType() { 73 + public RecipeType<? extends Recipe<CraftingInput>> 74 + getType() { 76 75 return Type.INSTANCE; 77 76 } 77 + 78 + //? if >1.21.2 { 79 + @Override 80 + public PlacementInfo placementInfo() { 81 + return PlacementInfo.create(input); 82 + } 83 + //?} 78 84 79 85 @Override 80 86 public @NotNull ItemStack assemble( ··· 175 181 } 176 182 177 183 @Override 178 - public @NotNull RecipeSerializer<ChromaticColoringRecipe> getSerializer() { 184 + public RecipeSerializer<? extends Recipe<CraftingInput>> getSerializer() { 179 185 return ModItemFunctions.CHROMATIC_COLORING.get(); 180 186 } 181 187 ··· 186 192 @Override 187 193 public @NotNull MapCodec<ChromaticColoringRecipe> codec() { 188 194 return RecordCodecBuilder.mapCodec(instance -> instance.group( 189 - Ingredient.CODEC_NONEMPTY.fieldOf("input").forGetter(recipe -> recipe.input), 195 + //? if >1.21.2 { 196 + Ingredient.CODEC 197 + //?} else { 198 + /*Ingredient.CODEC_NONEMPTY 199 + *///?} 200 + .fieldOf("input").forGetter(recipe -> recipe.input), 190 201 ItemStack.STRICT_CODEC.fieldOf("output").forGetter(recipe -> recipe.output)) 191 202 .apply(instance, func)); 192 203 }
+3 -1
src/main/java/net/lerariemann/infinity/item/function/F4RechargingRecipe.java
··· 131 131 return defaultedList; 132 132 } 133 133 134 - @Override 134 + //? if <1.21.2 { 135 + /*@Override 135 136 public boolean canCraftInDimensions(int width, int height) { 136 137 return width*height >= 2; 137 138 } 139 + *///?} 138 140 139 141 @Override 140 142 public @NotNull RecipeSerializer<F4RechargingRecipe> getSerializer() {
+5 -1
src/main/java/net/lerariemann/infinity/item/function/SetAltarStateLootFunction.java
··· 44 44 45 45 @Override 46 46 protected @NotNull ItemStack run(ItemStack stack, LootContext context) { 47 - BlockState st = context.getParamOrNull(LootContextParams.BLOCK_STATE); 47 + //? if >1.21.2 { 48 + BlockState st = context.getOptionalParameter(LootContextParams.BLOCK_STATE); 49 + //?} else { 50 + /*BlockState st = context.getParamOrNull(LootContextParams.BLOCK_STATE); 51 + *///?} 48 52 if (st != null) { 49 53 //? if >1.21 { 50 54 stack.applyComponentsAndValidate(AltarBlock.toComponentChanges(st));
+6 -1
src/main/java/net/lerariemann/infinity/structure/SetupperStructure.java
··· 26 26 27 27 @Override 28 28 public @NotNull Optional<GenerationStub> findGenerationPoint(GenerationContext context) { 29 - Structure shadow = context.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(VersionMethods.id(id)); 29 + Structure shadow = context.registryAccess().lookupOrThrow(Registries.STRUCTURE) 30 + //? if >1.21.2 { 31 + .getValue(VersionMethods.id(id)); 32 + //?} else { 33 + /*.get(VersionMethods.id(id)); 34 + *///?} 30 35 return shadow == null ? Optional.empty() : ((StructureAccess) shadow).invokeFindGenerationPoint(context); 31 36 } 32 37
+27 -4
src/main/java/net/lerariemann/infinity/util/config/ConfigGenerator.java
··· 21 21 import net.minecraft.server.level.ServerLevel; 22 22 import net.minecraft.sounds.SoundEvent; 23 23 import net.minecraft.tags.BlockTags; 24 - import net.minecraft.util.random.WeightedRandomList; 24 + //? if >1.21.2 { 25 + import net.minecraft.util.random.Weighted; 26 + import net.minecraft.util.random.WeightedList; 27 + //?} else { 28 + /*import net.minecraft.util.random.WeightedRandomList; 29 + *///?} 25 30 import net.minecraft.world.effect.MobEffect; 26 31 import net.minecraft.world.entity.EntityType; 27 32 import net.minecraft.world.entity.MobCategory; ··· 307 312 return res; 308 313 } 309 314 310 - static ListTag genSpawns(WeightedRandomList<MobSpawnSettings.SpawnerData> entries) { 315 + static ListTag genSpawns( 316 + //? if >1.21.2 { 317 + WeightedList 318 + //?} else { 319 + /*WeightedRandomList 320 + *///?} 321 + <MobSpawnSettings.SpawnerData> entries) { 311 322 ListTag lst = new ListTag(); 312 323 entries.unwrap().forEach((entry) -> lst.add(genEntry(entry))); 313 324 return lst; 314 325 } 315 326 316 - static CompoundTag genEntry(MobSpawnSettings.SpawnerData entry) { 327 + static CompoundTag genEntry( 328 + //? if >1.21.2 { 329 + Weighted<MobSpawnSettings.SpawnerData> spawnerDataWeighted 330 + //?} else { 331 + /*MobSpawnSettings.SpawnerData entry 332 + *///?} 333 + ) { 334 + //? if >1.21.2 { 335 + MobSpawnSettings.SpawnerData entry = spawnerDataWeighted.value(); 336 + var weight = spawnerDataWeighted.weight(); 337 + //?} else { 338 + /*var weight = entry.getWeight().asInt(); 339 + *///?} 317 340 CompoundTag res = new CompoundTag(); 318 341 res.putString("type", BuiltInRegistries.ENTITY_TYPE.getKey(entry.type 319 342 //? if >1.21.9 ··· 327 350 //? if >1.21.9 328 351 () 329 352 ); 330 - res.putInt("weight", entry.getWeight().asInt()); 353 + res.putInt("weight", weight); 331 354 return res; 332 355 } 333 356
+7 -1
src/main/java/net/lerariemann/infinity/util/core/NbtUtils.java
··· 91 91 *///?} 92 92 } 93 93 static ListTag getList(CompoundTag data, String key, ListTag def, byte nbttype) { 94 - return data.contains(key) ? data.getList(key, nbttype) : def; 94 + return data.contains(key) ? data.getList(key 95 + //? if <1.21.2 96 + /*, nbttype*/ 97 + ) 98 + //? if <1.21.2 99 + /*.orElse(def)*/ 100 + : def; 95 101 } 96 102 97 103 static String getString(CompoundTag data, String key) {
+1 -1
src/main/java/net/lerariemann/infinity/util/teleport/InfinityPortal.java
··· 115 115 getTeleportTarget(Entity entity) { 116 116 if (portalShouldWork() && portalTo != null && worldTo != null) { 117 117 //? if >1.21.3 { 118 - return NetherPortalBlock.getTeleportTransitionFromExit(entity, posTo, portalTo, worldTo, 118 + return NetherPortalBlock.getDimensionTransitionFromExit(entity, posTo, portalTo, worldTo, 119 119 TeleportTransition.PLAY_PORTAL_SOUND.then(entityx -> entityx.placePortalTicket(posTo))); 120 120 //?} else if >1.21 { 121 121 /*return NetherPortalBlock.getTeleportTransitionFromExit(entity, posTo, portalTo, worldTo,