public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS =
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, "tealcrystal");
public static final RegistryObject<CreativeModeTab> TEAL_CRYSTAL_TAB =
CREATIVE_MODE_TABS.register("teal_crystal_tab",
() -> CreativeModeTab.builder()
.title(Component.literal("Teal Crystal Infection"))
.icon(() -> new ItemStack(ModItems.TEAL_CRYSTAL.get()))
.displayItems((params, output) -> {
output.accept(ModBlocks.TEAL_CRYSTAL_BLOCK.get());
output.accept(ModBlocks.INFECTED_STONE.get());
output.accept(ModItems.TEAL_CRYSTAL.get());
output.accept(ModItems.TEAL_CRYSTAL_SHARD.get());
output.accept(ModItems.INFECTED_SPAWN_EGG.get());
output.accept(ModItems.CRYSTAL_BEAST_SPAWN_EGG.get());
})
.build());
@SubscribeEvent
public static void onPlayerTick(PlayerTickEvent event) {
Player player = event.player;
BlockPos below = player.blockPosition().below();
if (player.level().getBlockState(below).is(ModBlocks.TEAL_CRYSTAL_BLOCK.get())) {
InfectionData data = InfectionData.get(player);
data.progress++;
player.addEffect(new MobEffectInstance(
MobEffects.MOVEMENT_SLOWDOWN,
10,
1,
false,
false
));
player.level().addParticle(
ParticleTypes.SCULK_SOUL,
player.getX(),
player.getY() + 1,
player.getZ(),
0,
0.03,
0
);
if (data.progress >= 200) {
data.setInfected(true);
}
} else {
InfectionData.get(player).progress = 0;
}
}
controller.setAnimation(
RawAnimation.begin().thenPlay("animation.player.infect")
);
if(grabTimer > 0){
victim.addEffect(
new MobEffectInstance(
MobEffects.MOVEMENT_SLOWDOWN,
20,
4
)
);
infectionProgress += 2;
}
if(infectionProgress >= 100){
victim.turnIntoInfected();
}
Player walks onto crystal
↓
Crystal particles appear
↓
Legs crystallize
↓
Movement slows
↓
Infected human notices player
↓
Runs toward player
↓
Grab animation starts
↓
Player struggles
↓
Crystal spreads across body
↓
Player becomes infected