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

iridescent conversions

+77 -2
+45
common/src/main/java/net/lerariemann/infinity/iridescence/Iridescence.java
··· 1 1 package net.lerariemann.infinity.iridescence; 2 2 3 + import dev.architectury.registry.registries.RegistrySupplier; 3 4 import net.lerariemann.infinity.InfinityMod; 4 5 import net.lerariemann.infinity.PlatformMethods; 6 + import net.lerariemann.infinity.entity.ModEntities; 7 + import net.lerariemann.infinity.entity.custom.ChaosCreeper; 5 8 import net.lerariemann.infinity.var.ModCriteria; 6 9 import net.lerariemann.infinity.var.ModPayloads; 7 10 import net.lerariemann.infinity.var.ModStats; 8 11 import net.minecraft.block.Block; 9 12 import net.minecraft.client.network.ClientPlayerEntity; 13 + import net.minecraft.entity.EntityType; 10 14 import net.minecraft.entity.LivingEntity; 11 15 import net.minecraft.entity.effect.StatusEffectInstance; 16 + import net.minecraft.entity.mob.*; 12 17 import net.minecraft.fluid.FluidState; 13 18 import net.minecraft.registry.Registries; 19 + import net.minecraft.registry.entry.RegistryEntry; 14 20 import net.minecraft.server.network.ServerPlayerEntity; 15 21 import net.minecraft.server.world.ServerWorld; 22 + import net.minecraft.sound.SoundEvents; 16 23 import net.minecraft.util.Identifier; 17 24 import net.minecraft.util.math.BlockPos; 18 25 import net.minecraft.world.World; 19 26 import net.minecraft.world.WorldAccess; 27 + import net.minecraft.world.biome.Biome; 20 28 import org.jetbrains.annotations.Nullable; 21 29 22 30 import java.awt.*; 23 31 import java.util.List; 32 + import java.util.Map; 24 33 import java.util.Random; 25 34 26 35 public class Iridescence { ··· 128 137 public static Identifier getIdForWarp(ServerPlayerEntity player) { 129 138 ServerWorld w = player.getServerWorld().getServer().getOverworld(); 130 139 return InfinityMod.getDimId(new Random(w.getSeed() + w.getTime() / ticksInHour).nextInt()); 140 + } 141 + 142 + public static final Map<EntityType<? extends MobEntity>, RegistrySupplier<? extends EntityType<? extends MobEntity>>> convertibles = 143 + Map.ofEntries(Map.entry(EntityType.SKELETON, ModEntities.CHAOS_SKELETON), 144 + Map.entry(EntityType.CREEPER, ModEntities.CHAOS_CREEPER), 145 + Map.entry(EntityType.SLIME, ModEntities.CHAOS_SLIME) 146 + ); 147 + 148 + public static EntityType<? extends MobEntity> getConversion(MobEntity entity) { 149 + return convertibles.get(entity.getType()).get(); 150 + } 151 + 152 + public static void tryBeginConversion(MobEntity ent) { 153 + if (convertibles.containsKey(ent.getType()) && !ent.hasStatusEffect(ModStatusEffects.IRIDESCENT_EFFECT)) 154 + ent.addStatusEffect(new StatusEffectInstance(ModStatusEffects.IRIDESCENT_EFFECT, ticksInHour, 0)); 155 + } 156 + 157 + public static void endConversion(MobEntity currEntity) { 158 + EntityType<? extends MobEntity> typeNew = Iridescence.getConversion(currEntity); 159 + if (typeNew != null) { 160 + MobEntity newEntity = typeNew.create(currEntity.getWorld()); 161 + if (newEntity != null) { 162 + currEntity.discard(); 163 + ModEntities.copy(currEntity, newEntity); 164 + if (currEntity instanceof SlimeEntity e1 && newEntity instanceof SlimeEntity e2) { 165 + e1.setSize(e2.getSize(), true); 166 + } 167 + if (newEntity instanceof ChaosCreeper creeper) { 168 + RegistryEntry<Biome> b = creeper.getWorld().getBiome(creeper.getBlockPos()); 169 + creeper.setBiome(b.getIdAsString()); 170 + creeper.setColor(b.value().getFoliageColor()); 171 + } 172 + currEntity.getWorld().spawnEntity(newEntity); 173 + newEntity.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CONVERTED, 1.0f, 1.0f); 174 + } 175 + } 131 176 } 132 177 133 178 public enum Phase {
+4
common/src/main/java/net/lerariemann/infinity/iridescence/IridescenceLiquidBlock.java
··· 3 3 import dev.architectury.core.block.ArchitecturyLiquidBlock; 4 4 import net.minecraft.block.BlockState; 5 5 import net.minecraft.entity.Entity; 6 + import net.minecraft.entity.mob.MobEntity; 6 7 import net.minecraft.entity.player.PlayerEntity; 7 8 import net.minecraft.fluid.FlowableFluid; 8 9 import net.minecraft.util.math.BlockPos; ··· 20 21 super.onEntityCollision(state, world, pos, entity); 21 22 if (entity instanceof PlayerEntity player) { 22 23 Iridescence.tryBeginJourney(player, 4); 24 + } 25 + else if (entity instanceof MobEntity ent) { 26 + Iridescence.tryBeginConversion(ent); 23 27 } 24 28 } 25 29 }
+4
common/src/main/java/net/lerariemann/infinity/iridescence/IridescentEffect.java
··· 5 5 import net.minecraft.entity.effect.StatusEffect; 6 6 import net.minecraft.entity.effect.StatusEffectCategory; 7 7 import net.minecraft.entity.effect.StatusEffectInstance; 8 + import net.minecraft.entity.mob.MobEntity; 8 9 import net.minecraft.particle.EntityEffectParticleEffect; 9 10 import net.minecraft.particle.ParticleEffect; 10 11 import net.minecraft.particle.ParticleTypes; ··· 31 32 entity.setInvulnerable(false); 32 33 if (entity instanceof ServerPlayerEntity player) { 33 34 Iridescence.updateShader(player); 35 + } 36 + else if (entity instanceof MobEntity currEntity) { 37 + Iridescence.endConversion(currEntity); 34 38 } 35 39 } 36 40
+21
common/src/main/java/net/lerariemann/infinity/mixin/iridescence/LivingEntityRendererMixin.java
··· 1 + package net.lerariemann.infinity.mixin.iridescence; 2 + 3 + import net.lerariemann.infinity.iridescence.Iridescence; 4 + import net.lerariemann.infinity.iridescence.ModStatusEffects; 5 + import net.minecraft.client.render.entity.LivingEntityRenderer; 6 + import net.minecraft.entity.LivingEntity; 7 + import net.minecraft.entity.mob.MobEntity; 8 + import org.spongepowered.asm.mixin.Mixin; 9 + import org.spongepowered.asm.mixin.injection.At; 10 + import org.spongepowered.asm.mixin.injection.Inject; 11 + import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 + 13 + @Mixin(LivingEntityRenderer.class) 14 + public class LivingEntityRendererMixin { 15 + @Inject(method = "isShaking", at = @At("RETURN"), cancellable = true) 16 + void inj(LivingEntity entity, CallbackInfoReturnable<Boolean> cir) { 17 + if (entity instanceof MobEntity ent && Iridescence.convertibles.containsKey(ent.getType())) { 18 + cir.setReturnValue(cir.getReturnValue() || ent.hasStatusEffect(ModStatusEffects.IRIDESCENT_EFFECT)); 19 + } 20 + } 21 + }
+2 -2
common/src/main/resources/data/infinity/worldgen/biome/chaos.json
··· 7 7 "sky_color": 65535, 8 8 "water_color": 255, 9 9 "water_fog_color": 65535, 10 - "foliage_color": 16776960, 11 - "grass_color": 16711935 10 + "foliage_color": 16711935, 11 + "grass_color": 16776960 12 12 }, 13 13 "features": [ 14 14 [],
+1
common/src/main/resources/infinity.mixins.json
··· 45 45 ], 46 46 "client": [ 47 47 "client.EntityMixin", 48 + "iridescence.LivingEntityRendererMixin", 48 49 "iridescence.PostEffectProcessorMixin", 49 50 "options.BackgroundRendererMixin", 50 51 "options.ClientWorldMixin",