diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/WhisperwoodsMod.java b/common/src/main/java/dev/itsmeow/whisperwoods/WhisperwoodsMod.java index 3cb8ed7..8380c4f 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/WhisperwoodsMod.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/WhisperwoodsMod.java @@ -1,11 +1,8 @@ package dev.itsmeow.whisperwoods; -import dev.architectury.injectables.annotations.ExpectPlatform; -import dev.architectury.utils.PlatformExpectedError; import dev.itsmeow.imdlib.IMDLib; import dev.itsmeow.whisperwoods.init.*; import dev.itsmeow.whisperwoods.network.WWNetwork; -import net.minecraft.world.item.CreativeModeTab; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,7 +11,7 @@ public class WhisperwoodsMod { public static final String MODID = "whisperwoods"; - private static final Logger LOGGER = LogManager.getLogger(); + public static final Logger LOGGER = LogManager.getLogger(); public static void construct() { IMDLib.setRegistry(MODID); @@ -26,6 +23,7 @@ public static void construct() { ModBlocks.init(); ModItems.init(); ModBlockEntities.init(); + ModCreativeTabs.init(); WWNetwork.init(); LOGGER.info("Spooking you..."); } @@ -34,11 +32,4 @@ public static void init(Consumer enqueue) { LOGGER.info("Summoning a hidebehind to eat you..."); } - public static final CreativeModeTab TAB = getPlatformTab(); - - @ExpectPlatform - public static CreativeModeTab getPlatformTab() { - throw new PlatformExpectedError("getPlatformTab(): Expected Platform"); - } - } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/block/GhostLightBlock.java b/common/src/main/java/dev/itsmeow/whisperwoods/block/GhostLightBlock.java index 554fd0d..e4cdf51 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/block/GhostLightBlock.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/block/GhostLightBlock.java @@ -10,7 +10,6 @@ import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -18,16 +17,16 @@ public class GhostLightBlock extends Block implements EntityBlock, IHaveColor { - private static VoxelShape SHAPE; + private static final VoxelShape SHAPE; static { double d = 0.0625D * 5; SHAPE = Shapes.box(d, 0.0D, d, 1D - d, 1D - d, 1D - d); } - private int color = 0; + private int color; public GhostLightBlock(int color) { - super(Properties.of(Material.DECORATION).sound(SoundType.LANTERN).lightLevel(state -> 12)); + super(Properties.of().sound(SoundType.LANTERN).lightLevel(state -> 12)); this.color = color; } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/block/WispLanternBlock.java b/common/src/main/java/dev/itsmeow/whisperwoods/block/WispLanternBlock.java index ba6fed0..9b6ffc3 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/block/WispLanternBlock.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/block/WispLanternBlock.java @@ -21,7 +21,6 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -29,7 +28,7 @@ public class WispLanternBlock extends Block implements EntityBlock, SimpleWaterloggedBlock, IHaveColor { - private static VoxelShape[] SHAPES = new VoxelShape[Direction.values().length]; + private static final VoxelShape[] SHAPES = new VoxelShape[Direction.values().length]; static { for(Direction facing : Direction.values()) { final double d = 0.0625D * 4; @@ -47,7 +46,7 @@ public class WispLanternBlock extends Block implements EntityBlock, SimpleWaterl public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final DirectionProperty HORIZONTAL_FACING = DirectionProperty.create("horizontal", Direction.Plane.HORIZONTAL); - private int color = 0; + private int color; public WispLanternBlock(int color, Properties properties) { super(properties); @@ -79,7 +78,7 @@ public BlockState getStateForPlacement(BlockPlaceContext context) { if(direction.getAxis() == Axis.Y) { blockstate = blockstate.setValue(HORIZONTAL_FACING, context.getPlayer().getMotionDirection().getOpposite()); } - return blockstate.setValue(WATERLOGGED, Boolean.valueOf(fluidstate.getType() == Fluids.WATER)); + return blockstate.setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER); } } @@ -97,11 +96,6 @@ public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { return Block.canSupportCenter(worldIn, pos.relative(direction), direction.getOpposite()); } - @Override - public PushReaction getPistonPushReaction(BlockState state) { - return PushReaction.DESTROY; - } - @SuppressWarnings("deprecation") @Override public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/blockentity/HandOfFateBlockEntity.java b/common/src/main/java/dev/itsmeow/whisperwoods/blockentity/HandOfFateBlockEntity.java index 5e36444..05cb934 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/blockentity/HandOfFateBlockEntity.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/blockentity/HandOfFateBlockEntity.java @@ -2,9 +2,6 @@ import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableList; -import com.mojang.math.Vector3f; -import dev.architectury.registry.registries.Registries; -import dev.itsmeow.whisperwoods.WhisperwoodsMod; import dev.itsmeow.whisperwoods.block.GhostLightBlock; import dev.itsmeow.whisperwoods.block.HandOfFateBlock; import dev.itsmeow.whisperwoods.entity.EntityWisp; @@ -19,7 +16,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; @@ -52,6 +49,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.Shapes; +import org.joml.Vector3f; import java.util.LinkedHashMap; import java.util.List; @@ -94,8 +92,7 @@ public void sync() { public boolean isLit() { Block b = this.getBlockState().getBlock(); - if (b instanceof HandOfFateBlock && this.hasLevel()) { - HandOfFateBlock block = (HandOfFateBlock) b; + if (b instanceof HandOfFateBlock block && this.hasLevel()) { return block.isLit(this.getLevel(), this.getBlockPos()); } return false; @@ -138,12 +135,11 @@ public static void serverTick(Level level, Blo } blockEntity.setChanged(); break; - } else if (stack.getItem() instanceof BlockItem && level.isEmptyBlock(pos.above())) { - BlockItem i = (BlockItem) stack.getItem(); - if (i.getBlock() instanceof GhostLightBlock) { + } else if (stack.getItem() instanceof BlockItem blockItem && level.isEmptyBlock(pos.above())) { + if (blockItem.getBlock() instanceof GhostLightBlock) { item.getItem().shrink(1); blockEntity.playSound(SoundEvents.END_PORTAL_FRAME_FILL, 1F, 1F); - level.setBlockAndUpdate(pos.above(), i.getBlock().defaultBlockState()); + level.setBlockAndUpdate(pos.above(), blockItem.getBlock().defaultBlockState()); } if (item.getItem().getCount() == 0) { item.discard(); @@ -192,15 +188,14 @@ public InteractionResult reactToItem(ItemStack stack, BlockState state, Level wo } public void onRecipeComplete(HOFRecipe recipe, BlockState state, Level worldIn, BlockPos pos) { - if (worldIn instanceof ServerLevel && !worldIn.isClientSide) { - ServerLevel world = (ServerLevel) worldIn; + if (worldIn instanceof ServerLevel world && !worldIn.isClientSide) { switch (recipe.getName()) { case "hirschgeist": HOFEffectPacket hgpk = new HOFEffectPacket(HOFEffectType.HIRSCHGEIST, new Vector3f(pos.getX() + 0.5F, pos.getY() + 1F, pos.getZ() + 0.5F), WispColors.BLUE.getColor()); this.sendToTrackers(hgpk); this.playSound(SoundEvents.EVOKER_CAST_SPELL, 1F, 1F); this.playSound(SoundEvents.BELL_RESONATE, 1F, 1F); - TaskQueue.QUEUE_SERVER.schedule(50, () -> ModEntities.HIRSCHGEIST.getEntityType().spawn((ServerLevel) worldIn, null, null, pos.above(), MobSpawnType.EVENT, false, false)); + TaskQueue.QUEUE_SERVER.schedule(50, () -> ModEntities.HIRSCHGEIST.getEntityType().spawn((ServerLevel) worldIn, (CompoundTag) null, null, pos.above(), MobSpawnType.EVENT, false, false)); break; case "wisp": EntityWisp wisp = ModEntities.WISP.getEntityType().create(world); @@ -267,7 +262,7 @@ public void dropItems(Level worldIn, BlockPos pos) { if (worldIn != null && this.getRecipeContainer().hasRecipe() && this.getRecipeContainer().data != null) { this.getRecipeContainer().data.getItemData().forEach((i, v) -> { if (v) { - Item toDrop = Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).get(new ResourceLocation(i)); + Item toDrop = BuiltInRegistries.ITEM.get(new ResourceLocation(i)); if (toDrop != null) { Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(toDrop)); } @@ -318,7 +313,7 @@ public boolean canRecipeAccept(Item item) { if (this.hasRecipe() && data != null) { String next = data.getNextNonContainedItem(); if (next != null) { - return next.equals(Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString()); + return next.equals(BuiltInRegistries.ITEM.getKey(item).toString()); } } return false; @@ -332,7 +327,7 @@ public Item getDisplayItem() { if (this.hasRecipe() && data != null) { String itemName = data.getNextNonContainedItem(); if (itemName != null) { - return Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).get(new ResourceLocation(itemName)); + return BuiltInRegistries.ITEM.get(new ResourceLocation(itemName)); } } return null; @@ -367,12 +362,12 @@ public static class RecipeItemData { private final Map data = new LinkedHashMap<>(); public RecipeItemData(HOFRecipe recipe) { - recipe.items.forEach(item -> data.put(Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString(), false)); + recipe.items.forEach(item -> data.put(BuiltInRegistries.ITEM.getKey(item).toString(), false)); } public RecipeItemData(HOFRecipe recipe, Set items) { recipe.items.forEach(item -> { - String key = Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString(); + String key = BuiltInRegistries.ITEM.getKey(item).toString(); data.put(key, items.contains(key)); }); } @@ -387,7 +382,7 @@ public String getNextNonContainedItem() { } public boolean addItem(Item item) { - String key = Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString(); + String key = BuiltInRegistries.ITEM.getKey(item).toString(); if (data.containsKey(key)) { data.put(key, true); return true; @@ -396,7 +391,7 @@ public boolean addItem(Item item) { } public boolean hasItem(Item item) { - return data.getOrDefault(Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString(), false); + return data.getOrDefault(BuiltInRegistries.ITEM.getKey(item).toString(), false); } public void read(CompoundTag nbt) { diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/client/init/ClientLifecycleHandler.java b/common/src/main/java/dev/itsmeow/whisperwoods/client/init/ClientLifecycleHandler.java index 09c8a38..44b2ac9 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/client/init/ClientLifecycleHandler.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/client/init/ClientLifecycleHandler.java @@ -55,11 +55,9 @@ public class ClientLifecycleHandler { public static void clientInit() { ClientReloadShadersEvent.EVENT.register((resourceManager, shadersSink) -> { try { - shadersSink.registerShader(new ShaderInstance(resourceManager,"ww_rendertype_eyes_custom", DefaultVertexFormat.NEW_ENTITY), shaderInstance -> { - RenderTypeAddition.eyesCustomShader = shaderInstance; - }); + shadersSink.registerShader(new ShaderInstance(resourceManager,"ww_rendertype_eyes_custom", DefaultVertexFormat.NEW_ENTITY), shaderInstance -> RenderTypeAddition.eyesCustomShader = shaderInstance); } catch (IOException e) { - e.printStackTrace(); + WhisperwoodsMod.LOGGER.error(e); } }); BlockEntityRendererRegistry.register(ModBlockEntities.GHOST_LIGHT.get(), RenderTileGhostLight::new); @@ -95,10 +93,10 @@ public void render(EntityHirschgeistFireball entity, float f, float g, PoseStack if(System.nanoTime() - entity.lastSpawn >= 10_000_000L) { entity.lastSpawn = System.nanoTime(); for(int j = 0; j < 5; j++) { - double xO = (entity.getRandom().nextFloat() * 2F - 1F); - double yO = (entity.getRandom().nextFloat() * 2F - 1F); - double zO = (entity.getRandom().nextFloat() * 2F - 1F); - entity.level.addParticle(ModParticles.SOUL_FLAME.get(), + double xO = (entity.level().getRandom().nextFloat() * 2F - 1F); + double yO = (entity.level().getRandom().nextFloat() * 2F - 1F); + double zO = (entity.level().getRandom().nextFloat() * 2F - 1F); + entity.level().addParticle(ModParticles.SOUL_FLAME.get(), entity.getX() + xO, entity.getY() + yO, entity.getZ() + zO, 0, 0.005F, 0); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderHirschgeist.java b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderHirschgeist.java index f43e753..cd03407 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderHirschgeist.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderHirschgeist.java @@ -20,7 +20,6 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Pose; -import java.util.Iterator; import java.util.List; public class RenderHirschgeist extends LivingEntityRenderer { @@ -46,9 +45,8 @@ public void render(EntityHirschgeist livingEntity, float f, float g, PoseStack p float j = Mth.rotLerp(g, livingEntity.yHeadRotO, livingEntity.yHeadRot); float k = j - h; float l; - if (livingEntity.isPassenger() && livingEntity.getVehicle() instanceof LivingEntity) { - LivingEntity livingEntity2 = (LivingEntity)livingEntity.getVehicle(); - h = Mth.rotLerp(g, livingEntity2.yBodyRotO, livingEntity2.yBodyRot); + if (livingEntity.isPassenger() && livingEntity.getVehicle() instanceof LivingEntity mount) { + h = Mth.rotLerp(g, mount.yBodyRotO, mount.yBodyRot); k = j - h; l = Mth.wrapDegrees(k); if (l < -85.0F) { @@ -81,8 +79,8 @@ public void render(EntityHirschgeist livingEntity, float f, float g, PoseStack p n = 0.0F; float o = 0.0F; if (!livingEntity.isPassenger() && livingEntity.isAlive()) { - n = Mth.lerp(g, livingEntity.animationSpeedOld, livingEntity.animationSpeed); - o = livingEntity.animationPosition - livingEntity.animationSpeed * (1.0F - g); + n = livingEntity.walkAnimation.speed(g); + o = livingEntity.walkAnimation.position(g); if (livingEntity.isBaby()) { o *= 3.0F; } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderWisp.java b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderWisp.java index 28784db..3bb5fee 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderWisp.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/RenderWisp.java @@ -33,11 +33,11 @@ public void render(EntityWisp entity, float entityYaw, float partialTicks, PoseS float r = (color >> 16) & 0xFF; float g = (color >> 8) & 0xFF; float b = color & 0xFF; - float scale = 1; + float scale; if(entity.hasSoul()) { UUID target = UUID.fromString(entity.getEntityData().get(EntityWisp.TARGET_ID)); String name = entity.getEntityData().get(EntityWisp.TARGET_NAME); - if(target != null && name != null && !name.equals("")) { + if(target != null && name != null && !name.isEmpty()) { stack.pushPose(); { stack.translate(0F, 0.8F, 0F); @@ -64,13 +64,13 @@ public void render(EntityWisp entity, float entityYaw, float partialTicks, PoseS double xO = (entity.getRandom().nextFloat() * 2F - 1F) / 3.5; double yO = (entity.getRandom().nextFloat() * 2F - 1F) / 6 + 0.8F; double zO = (entity.getRandom().nextFloat() * 2F - 1F) / 3.5; - entity.level.addParticle(new WispParticleData(r, g, b, scale), + entity.level().addParticle(new WispParticleData(r, g, b, scale), entity.getX() + xO, entity.getY() + yO, entity.getZ() + zO, 0, 0.005F, 0); } // spawn upper particle - entity.level.addParticle(new WispParticleData(r, g, b, scale), + entity.level().addParticle(new WispParticleData(r, g, b, scale), entity.getX() + (entity.getRandom().nextFloat() * 2F - 1F) / 10, entity.getY() + (entity.getRandom().nextFloat() * 2F - 1F) / 5 + 1.1F, entity.getZ() + (entity.getRandom().nextFloat() * 2F - 1F) / 10, 0, 0.02F, 0); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelHirschgeist.java b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelHirschgeist.java index 2b45e30..b255640 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelHirschgeist.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelHirschgeist.java @@ -3,7 +3,6 @@ import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Matrix4f; import dev.itsmeow.whisperwoods.WhisperwoodsMod; import dev.itsmeow.whisperwoods.entity.EntityHirschgeist; import net.minecraft.client.Minecraft; @@ -14,13 +13,12 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; +import org.joml.Matrix4f; import java.util.List; public class ModelHirschgeist extends EntityModel { - private boolean isDaytime = false; - public ModelPart spine01; public ModelPart spine02; public ModelPart spine03; @@ -447,7 +445,6 @@ public void renderToBuffer(PoseStack poseStack, VertexConsumer bufferIn, int pac @Override public void setupAnim(EntityHirschgeist entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { - this.isDaytime = entityIn.isDaytimeClient(); float factor = 0.8F; this.lArm00.xRot = Mth.cos(limbSwing * 0.6662F) * factor * limbSwingAmount - 1.1344640137963142F; this.rArm00.xRot = Mth.cos(limbSwing * 0.6662F + (float) Math.PI) * factor * limbSwingAmount - 1.1344640137963142F; @@ -472,9 +469,9 @@ public static void render(PoseStack stack, ModelPart.Cube cube, float scale) { stack.translate(cube.minX / 16F, cube.minY / 16F, cube.minZ / 16F); Matrix4f d = stack.last().pose(); float ticks = ((float) Minecraft.getInstance().player.tickCount % 30) / 30F; - Matrix4f matrix = Matrix4f.createTranslateMatrix(d.m03 + ((float) Math.random() - 0.5F) / 100F, d.m13 + ((float) Math.random() - 0.5F) / 100F, d.m23 + ((float) Math.random() - 0.5F) / 100F); + Matrix4f matrix = new Matrix4f().translation(d.m03() + ((float) Math.random() - 0.5F) / 100F, d.m13() + ((float) Math.random() - 0.5F) / 100F, d.m23() + ((float) Math.random() - 0.5F) / 100F); float extraScale = (1F - ticks) + (float) Math.random() / 10F; - matrix.multiply(Matrix4f.createScaleMatrix(0.1F * scale, 0.1F * scale, 0.1F * scale)); + matrix.scale(0.1F * scale, 0.1F * scale, 0.1F * scale); RenderSystem.disableCull(); RenderSystem.enableDepthTest(); RenderSystem.setShader(GameRenderer::getPositionTexShader); @@ -492,9 +489,9 @@ public static void render(PoseStack stack, ModelPart.Cube cube, float scale) { bufferBuilder.vertex(matrix, 1F, -1F, 0F).uv(u0, v1).endVertex(); BufferUploader.drawWithShader(bufferBuilder.end()); - matrix = Matrix4f.createTranslateMatrix(d.m03, d.m13, d.m23 + 0.01F); - matrix.multiply(Matrix4f.createScaleMatrix(0.1F * scale, 0.1F * scale, 0.1F * scale)); - matrix.multiply(Matrix4f.createScaleMatrix(extraScale, extraScale, extraScale)); + matrix = new Matrix4f().translation(d.m03(), d.m13(), d.m23() + 0.01F); + matrix.scale(0.1F * scale, 0.1F * scale, 0.1F * scale); + matrix.scale(extraScale, extraScale, extraScale); bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); bufferBuilder.vertex(matrix, -1F, -1F, 0F).uv(u1, v1).endVertex(); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelMoth.java b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelMoth.java index 7497e67..47323ee 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelMoth.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/entity/model/ModelMoth.java @@ -96,7 +96,7 @@ public void setupAnim(EntityMoth entity, float limbSwing, float limbSwingAmount, this.thorax.yRot = (float) Math.toRadians(Direction.from3DDataValue(entity.getLandedInteger()).toYRot()); double x = Math.floor(entity.getX()) + 0.5D; double z = Math.floor(entity.getZ()) + 0.5D; - BlockPos pos = new BlockPos(x, entity.getY(), z); + BlockPos pos = BlockPos.containing(x, entity.getY(), z); BlockPos offset = pos.relative(Direction.from3DDataValue(entity.getLandedInteger())); BlockPos diff = pos.subtract(offset); this.xOff = ((double) diff.getX()) / (13D * entity.getDimensions(Pose.STANDING).width); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/tile/RenderTileHandOfFate.java b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/tile/RenderTileHandOfFate.java index 40fb084..3ed47c0 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/tile/RenderTileHandOfFate.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/client/renderer/tile/RenderTileHandOfFate.java @@ -1,35 +1,31 @@ package dev.itsmeow.whisperwoods.client.renderer.tile; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import dev.itsmeow.whisperwoods.WhisperwoodsMod; import dev.itsmeow.whisperwoods.block.GhostLightBlock; import dev.itsmeow.whisperwoods.block.HandOfFateBlock; import dev.itsmeow.whisperwoods.block.HandOfFateBlock.Orientation; import dev.itsmeow.whisperwoods.blockentity.HandOfFateBlockEntity; -import dev.itsmeow.whisperwoods.client.renderer.tile.model.ModelHGSkull; import dev.itsmeow.whisperwoods.client.renderer.tile.model.ModelHandOfFate; import dev.itsmeow.whisperwoods.particle.WispParticleData; import net.minecraft.client.Minecraft; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; -import java.util.Random; - public class RenderTileHandOfFate implements BlockEntityRenderer { - private static final ResourceLocation TEXTURE = new ResourceLocation(WhisperwoodsMod.MODID, "textures/blocks/hand_of_fate.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation(WhisperwoodsMod.MODID, "textures/block/hand_of_fate.png"); private final ModelHandOfFate model; - private Random rand = new Random(); private ItemStack istack = null; public RenderTileHandOfFate(BlockEntityRendererProvider.Context ctx) { @@ -40,10 +36,10 @@ public RenderTileHandOfFate(BlockEntityRendererProvider.Context ctx) { public void render(HandOfFateBlockEntity te, float partialTicks, PoseStack stack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { stack.pushPose(); stack.translate(0.5F, 1.5F, 0.5F); - stack.mulPose(Vector3f.ZP.rotationDegrees(180F)); + stack.mulPose(Axis.ZP.rotationDegrees(180F)); Orientation rot = te.getBlockState().getValue(HandOfFateBlock.ROTATION); float rotation = (float) rot.getHorizontalAngle(); - stack.mulPose(Vector3f.YP.rotationDegrees(rotation)); + stack.mulPose(Axis.YP.rotationDegrees(rotation)); model.renderToBuffer(stack, bufferIn.getBuffer(RenderType.entityCutoutNoCull(TEXTURE)), combinedLightIn, combinedOverlayIn, 1F, 1F, 1F, 1F); if(!Minecraft.getInstance().isPaused() && Minecraft.getInstance().player != null) { if(te.isLit()) { @@ -52,9 +48,9 @@ public void render(HandOfFateBlockEntity te, float partialTicks, PoseStack stack float r = (color >> 16) & 0xFF; float g = (color >> 8) & 0xFF; float b = color & 0xFF; - te.getLevel().addParticle(new WispParticleData(r, g, b, 0.5F), te.getBlockPos().getX() + (this.rand.nextFloat() + 0.5F) / 2, te.getBlockPos().getY() + this.rand.nextFloat(), te.getBlockPos().getZ() + (this.rand.nextFloat() + 0.5F) / 2, 0, 0.02F, 0); + te.getLevel().addParticle(new WispParticleData(r, g, b, 0.5F), te.getBlockPos().getX() + (te.getLevel().getRandom().nextFloat() + 0.5F) / 2, te.getBlockPos().getY() + te.getLevel().getRandom().nextFloat(), te.getBlockPos().getZ() + (te.getLevel().getRandom().nextFloat() + 0.5F) / 2, 0, 0.02F, 0); } else if(te.hasBlaze()) { - te.getLevel().addParticle(ParticleTypes.FLAME, te.getBlockPos().getX() + (this.rand.nextFloat() + 0.5F) / 2, te.getBlockPos().getY() + this.rand.nextFloat(), te.getBlockPos().getZ() + (this.rand.nextFloat() + 0.5F) / 2, 0, 0.02F, 0); + te.getLevel().addParticle(ParticleTypes.FLAME, te.getBlockPos().getX() + (te.getLevel().getRandom().nextFloat() + 0.5F) / 2, te.getBlockPos().getY() + te.getLevel().getRandom().nextFloat(), te.getBlockPos().getZ() + (te.getLevel().getRandom().nextFloat() + 0.5F) / 2, 0, 0.02F, 0); } } stack.popPose(); @@ -67,12 +63,12 @@ public void render(HandOfFateBlockEntity te, float partialTicks, PoseStack stack float y = Mth.sin((float) Minecraft.getInstance().level.getGameTime() * 0.05F) / 8F; stack.translate(0F, Mth.lerp(partialTicks, te.lastAnimationY, y), 0F); te.lastAnimationY = y; - stack.mulPose(Vector3f.YP.rotationDegrees(rotation + (rot.getHorizontalAngle() % 90F == 0 ? 0F : 90F))); + stack.mulPose(Axis.YP.rotationDegrees(rotation + (rot.getHorizontalAngle() % 90F == 0 ? 0F : 90F))); stack.scale(0.25F, 0.25F, 0.25F); if(istack == null || istack.getItem() != display) { istack = new ItemStack(display); } - Minecraft.getInstance().getItemRenderer().renderStatic(istack, TransformType.NONE, combinedLightIn, combinedOverlayIn, stack, bufferIn, 0); + Minecraft.getInstance().getItemRenderer().renderStatic(istack, ItemDisplayContext.NONE, combinedLightIn, combinedOverlayIn, stack, bufferIn, null, ItemDisplayContext.NONE.ordinal()); } stack.popPose(); } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHidebehind.java b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHidebehind.java index 03cf691..b643ba0 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHidebehind.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHidebehind.java @@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.registries.Registries; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; @@ -23,7 +24,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.EntityDamageSource; +import net.minecraft.world.damagesource.DamageType; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; @@ -57,8 +58,7 @@ import java.util.function.Supplier; public class EntityHidebehind extends EntityCreatureWithSelectiveTypes implements IOverrideCollisions { - - public final DamageSource HIDEBEHIND = new EntityDamageSource("hidebehind", this).bypassMagic().bypassArmor(); + public static final ResourceKey HIDEBEHIND = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(WhisperwoodsMod.MODID, "hidebehind")); protected static final EntityDataAccessor HIDING = SynchedEntityData.defineId(EntityHidebehind.class, EntityDataSerializers.INT); protected static final EntityDataAccessor OPEN = SynchedEntityData.defineId(EntityHidebehind.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor ATTACK_SEQUENCE_TICKS = SynchedEntityData.defineId(EntityHidebehind.class, EntityDataSerializers.INT); @@ -66,7 +66,7 @@ public class EntityHidebehind extends EntityCreatureWithSelectiveTypes implement public EntityHidebehind(EntityType type, Level world) { super(type, world); - this.maxUpStep = 2F; + this.setMaxUpStep(2F); } @Override @@ -125,7 +125,7 @@ public boolean hurt(DamageSource source, float amount) { if(source.getEntity() == this.getTarget() && this.attackSequenceTicks() > 0) { this.setAttackSequenceTicks(0); } - if (!level.isClientSide()) { + if (!level().isClientSide()) { boolean isImmediate = source.getDirectEntity() instanceof Player; Player player = isImmediate ? (Player) source.getDirectEntity() : (source.getEntity() instanceof Player ? (Player) source.getEntity() : null); if (player != null) { @@ -136,7 +136,7 @@ public boolean hurt(DamageSource source, float amount) { if (!player.isCreative()) { player.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 15 * (hiding == 1 ? 5 : 20), 0)); if (player.distanceTo(this) < 3) - player.hurt(HIDEBEHIND, 1F); + player.hurt(hideBehindDamageSource(), 1F); } HideFromTargetGoal.doTreeTick(this); return super.hurt(source, amount * (hiding == 1 ? 0.5F : 0.25F)); @@ -146,6 +146,10 @@ public boolean hurt(DamageSource source, float amount) { return super.hurt(source, amount); } + private DamageSource hideBehindDamageSource() { + return new DamageSource(this.level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(HIDEBEHIND), this); + } + @Override public void tick() { super.tick(); @@ -162,7 +166,7 @@ public void tick() { for(int i1 = 0; i1 <= l; i1 = i1 > 0 ? -i1 : 1 - i1) { for(int j1 = i1 < l && i1 > -l ? l : 0; j1 <= l; j1 = j1 > 0 ? -j1 : 1 - j1) { bp.set(this.blockPosition()).move(i1, k - 1, j1); - if(this.level.getBlockState(bp).is(BlockTags.LOGS)) { + if(this.level().getBlockState(bp).is(BlockTags.LOGS)) { destinationBlock = bp.immutable(); } } @@ -173,7 +177,7 @@ public void tick() { if(destinationBlock != null) { for(Direction dir : Direction.values()) { if(!fixed) { - if(this.level.isEmptyBlock(destinationBlock.relative(dir)) || this.level.getBlockState(destinationBlock.relative(dir)).is(BlockTags.LEAVES)) { + if(this.level().isEmptyBlock(destinationBlock.relative(dir)) || this.level().getBlockState(destinationBlock.relative(dir)).is(BlockTags.LEAVES)) { destinationBlock = destinationBlock.relative(dir); fixed = true; } @@ -184,8 +188,8 @@ public void tick() { this.teleportTo(destinationBlock.getX(), destinationBlock.getY(), destinationBlock.getZ()); } } - if(!level.isClientSide()) { - if (level.isDay() && level.getBrightness(LightLayer.SKY, this.blockPosition()) > 10) { + if(!level().isClientSide()) { + if (level().isDay() && level().getBrightness(LightLayer.SKY, this.blockPosition()) > 10) { this.setHiding(2); } else if (this.getHidingInt() == 2) { this.setHiding(1); @@ -196,9 +200,8 @@ public void tick() { } float atkTicks = attackSequenceTicks(); if(this.getTarget() != null && this.getTarget().distanceToSqr(this) < 5D && atkTicks == 0 && !this.getHiding() && this.isEntityAttackable(this.getTarget())) { - if(this.getTarget() instanceof Player) { - Player player = (Player) this.getTarget(); - if(!this.level.isClientSide && this.getRandom().nextInt(20) == 0) { + if(this.getTarget() instanceof Player player) { + if(!this.level().isClientSide && this.getRandom().nextInt(20) == 0) { if(player.getHealth() > this.getAttribute(Attributes.ATTACK_DAMAGE).getValue()) { this.doHurtTarget(player); } else { @@ -238,7 +241,7 @@ public void tick() { this.getLookControl().setLookAt(target, 360F, 360F); } this.attackSequenceTicksDecrement(); - if(atkTicks - 1 == 0 && !level.isClientSide()) { + if(atkTicks - 1 == 0 && !level().isClientSide()) { this.setOpen(false); if(this.getTarget() != null) { this.doHurtTarget(target); @@ -261,7 +264,7 @@ public static Player getTargetClient() { public boolean isEntityAttackable(LivingEntity target) { Item mainItem = target.getItemInHand(InteractionHand.MAIN_HAND).getItem(); Item offItem = target.getItemInHand(InteractionHand.OFF_HAND).getItem(); - return level.getMaxLocalRawBrightness(target.blockPosition()) < 8 && !(mainItem instanceof BlockItem && ((BlockItem)mainItem).getBlock() instanceof TorchBlock) && !(offItem instanceof BlockItem && ((BlockItem)offItem).getBlock() instanceof TorchBlock); + return level().getMaxLocalRawBrightness(target.blockPosition()) < 8 && !(mainItem instanceof BlockItem && ((BlockItem)mainItem).getBlock() instanceof TorchBlock) && !(offItem instanceof BlockItem && ((BlockItem)offItem).getBlock() instanceof TorchBlock); } @Override @@ -340,7 +343,7 @@ public boolean doHurtTarget(Entity entity) { entity.setSecondsOnFire(i * 4); } - boolean flag = entity.hurt(HIDEBEHIND, f); + boolean flag = entity.hurt(hideBehindDamageSource(), f); if (flag) { if (f1 > 0.0F && entity instanceof LivingEntity) { ((LivingEntity)entity).knockback(f1 * 0.5F, (double)Mth.sin(this.getYRot() * 0.017453292F), (double)(-Mth.cos(this.getYRot() * 0.017453292F))); @@ -409,10 +412,10 @@ public static void doTreeTick(EntityHidebehind hidebehind) { boolean nearTree = false; for(Direction dir : Direction.values()) { if(!nearTree) { - if(hidebehind.level.getBlockState(hidebehind.blockPosition().relative(dir)).is(BlockTags.LOGS)) { + if(hidebehind.level().getBlockState(hidebehind.blockPosition().relative(dir)).is(BlockTags.LOGS)) { nearTree = true; } - if(hidebehind.level.getBlockState(hidebehind.blockPosition().above(3).relative(dir)).is(BlockTags.LEAVES)) { + if(hidebehind.level().getBlockState(hidebehind.blockPosition().above(3).relative(dir)).is(BlockTags.LEAVES)) { nearTree = true; } } @@ -427,7 +430,7 @@ public static void doTreeTick(EntityHidebehind hidebehind) { for(int i1 = 0; i1 <= l; i1 = i1 > 0 ? -i1 : 1 - i1) { for(int j1 = i1 < l && i1 > -l ? l : 0; j1 <= l; j1 = j1 > 0 ? -j1 : 1 - j1) { blockpos$mutableblockpos.set(hidebehind.blockPosition()).move(i1, k - 1, j1); - if(hidebehind.level.getBlockState(blockpos$mutableblockpos).is(BlockTags.LOGS)) { + if(hidebehind.level().getBlockState(blockpos$mutableblockpos).is(BlockTags.LOGS)) { destinationBlock = blockpos$mutableblockpos.immutable(); } } @@ -438,7 +441,7 @@ public static void doTreeTick(EntityHidebehind hidebehind) { if(destinationBlock != null) { for(Direction dir : Direction.values()) { if(!fixed) { - if(hidebehind.level.isEmptyBlock(destinationBlock.relative(dir)) || hidebehind.level.getBlockState(destinationBlock.relative(dir)).is(BlockTags.LEAVES)) { + if(hidebehind.level().isEmptyBlock(destinationBlock.relative(dir)) || hidebehind.level().getBlockState(destinationBlock.relative(dir)).is(BlockTags.LEAVES)) { destinationBlock = destinationBlock.relative(dir); fixed = true; } @@ -463,7 +466,7 @@ protected void defineSynchedData() { @Override public boolean removeWhenFarAway(double range) { - return level.isDay() && super.removeWhenFarAway(range); + return level().isDay() && super.removeWhenFarAway(range); } @Override @@ -486,8 +489,8 @@ protected PathFinder createPathFinder(int i1) { public static class HidebehindNodeProcessor extends WalkNodeEvaluator { @Override - protected BlockPathTypes evaluateBlockPathType(BlockGetter reader, boolean b1, boolean b2, BlockPos pos, BlockPathTypes typeIn) { - return typeIn == BlockPathTypes.LEAVES ? BlockPathTypes.OPEN : super.evaluateBlockPathType(reader, b1, b2, pos, typeIn); + protected BlockPathTypes evaluateBlockPathType(BlockGetter reader, BlockPos pos, BlockPathTypes typeIn) { + return typeIn == BlockPathTypes.LEAVES ? BlockPathTypes.OPEN : super.evaluateBlockPathType(reader, pos, typeIn); } } @@ -542,7 +545,7 @@ public EntityTypeContainer getContainer() { @Override public String[] getTypesFor(ResourceKey biomeKey, Biome biome, Set types, MobSpawnType reason) { - if(biomeKey == Biomes.OLD_GROWTH_SPRUCE_TAIGA || biomeKey == Biomes.OLD_GROWTH_SPRUCE_TAIGA) { + if(biomeKey == Biomes.OLD_GROWTH_SPRUCE_TAIGA) { return new String[] { "mega_taiga", "mega_taiga", "mega_taiga", "darkforest" }; } if(types.contains(BiomeTypes.CONIFEROUS)) { diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHirschgeist.java b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHirschgeist.java index bb975d2..f88065c 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHirschgeist.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityHirschgeist.java @@ -21,9 +21,11 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.BlockTags; +import net.minecraft.util.Mth; import net.minecraft.world.BossEvent; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.goal.FloatGoal; import net.minecraft.world.entity.ai.goal.Goal; @@ -57,7 +59,7 @@ public class EntityHirschgeist extends Monster implements Enemy, IOverrideCollis public EntityHirschgeist(EntityType entityType, Level worldIn) { super(entityType, worldIn); this.xpReward = 150; - this.maxUpStep = 1.5F; + this.setMaxUpStep(1.5F); } @Override @@ -98,8 +100,8 @@ protected PathNavigation createNavigation(Level worldIn) { protected PathFinder createPathFinder(int i1) { this.nodeEvaluator = new WalkNodeEvaluator() { @Override - protected BlockPathTypes evaluateBlockPathType(BlockGetter reader, boolean b1, boolean b2, BlockPos pos, BlockPathTypes typeIn) { - return typeIn == BlockPathTypes.LEAVES || reader.getBlockState(pos).is(BlockTags.LOGS) || reader.getBlockState(pos).is(BlockTags.LEAVES) ? BlockPathTypes.OPEN : super.evaluateBlockPathType(reader, b1, b2, pos, typeIn); + protected BlockPathTypes evaluateBlockPathType(BlockGetter reader, BlockPos pos, BlockPathTypes typeIn) { + return typeIn == BlockPathTypes.LEAVES || reader.getBlockState(pos).is(BlockTags.LOGS) || reader.getBlockState(pos).is(BlockTags.LEAVES) ? BlockPathTypes.OPEN : super.evaluateBlockPathType(reader, pos, typeIn); } }; this.nodeEvaluator.setCanPassDoors(true); @@ -160,8 +162,7 @@ public boolean doHurtTarget(Entity entityIn) { if (entityIn instanceof LivingEntity) { ((LivingEntity) entityIn).knockback(2F, this.getX() - entityIn.getX(), this.getZ() - entityIn.getZ()); entityIn.setSecondsOnFire(2 + this.getRandom().nextInt(2)); - if(level instanceof ServerLevel) { - ServerLevel serverLevel = (ServerLevel) level; + if(level() instanceof ServerLevel serverLevel) { serverLevel.sendParticles(ParticleTypes.SOUL_FIRE_FLAME, this.position().x() + ((entityIn.position().x() - this.position().x()) / 2D), this.position().y() + ((entityIn.position().y() - this.position().y()) / 2D), this.position().z() + ((entityIn.position().z() - this.position().z()) / 2D), 500, Math.abs((entityIn.position().x() - this.position().x()) / 25D), 0, Math.abs((entityIn.position().z() - this.position().z()) / 25D), 0.1D); } } @@ -186,14 +187,14 @@ public void tick() { } } this.bossInfo.setProgress(this.getHealth() / this.getMaxHealth()); - if (!level.isClientSide) { + if (!level().isClientSide) { this.getEntityData().set(DISTANCE_TO_TARGET, this.getTarget() == null ? -1F : this.getTarget().distanceTo(this)); this.getEntityData().set(DAYTIME, this.isDaytime()); } } public boolean isDaytime() { - return this.level.isDay(); + return this.level().isDay(); } public boolean isDaytimeClient() { @@ -212,18 +213,18 @@ public boolean isInvulnerable() { @Override public boolean isInvulnerableTo(DamageSource source) { - return (this.isDaytime() && source != DamageSource.OUT_OF_WORLD && !source.isCreativePlayer()) || source.getEntity() instanceof EntityHirschgeist || source == DamageSource.MAGIC || source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE || source == DamageSource.LAVA; + return (this.isDaytime() && !source.is(DamageTypes.FELL_OUT_OF_WORLD) && !source.is(DamageTypes.OUTSIDE_BORDER) && !source.isCreativePlayer()) || source.getEntity() instanceof EntityHirschgeist || source.is(DamageTypes.MAGIC) || source.is(DamageTypes.IN_FIRE) || source.is(DamageTypes.ON_FIRE) || source.is(DamageTypes.LAVA); } @Override public boolean hurt(DamageSource source, float amount) { - if(!this.level.isClientSide && source.getEntity() instanceof Player && !source.isCreativePlayer()) { + if(!this.level().isClientSide && source.getEntity() instanceof Player && !source.isCreativePlayer()) { if (this.isDaytime()) { Player player = (Player) source.getEntity(); player.sendSystemMessage(Component.translatable("entity.whisperwoods.hirschgeist.message.invulnerable")); return false; } else if (this.getRandom().nextInt(4) == 0) { - this.level.playSound(null, source.getEntity(), SoundEvents.BUCKET_FILL_LAVA, SoundSource.MASTER, 1F, 2F); + this.level().playSound(null, source.getEntity(), SoundEvents.BUCKET_FILL_LAVA, SoundSource.MASTER, 1F, 2F); return false; } } @@ -314,11 +315,11 @@ public void start() { double d1 = target.getY() - this.attacker.getEyeY() - 0.1D; double d2 = target.getZ() - this.attacker.getZ(); double d3 = Math.sqrt(d0 * d0 + d2 * d2); - EntityHirschgeistFireball ball = new EntityHirschgeistFireball(ModEntities.PROJECTILE_HIRSCHGEIST_FIREBALL.get(), this.attacker.level, this.attacker); + EntityHirschgeistFireball ball = new EntityHirschgeistFireball(ModEntities.PROJECTILE_HIRSCHGEIST_FIREBALL.get(), this.attacker.level(), this.attacker); ball.setPos(target.getX(), target.getEyeY() - 0.1D, target.getZ()); ball.shoot(d0, d1 + d3 * 0.2D, d2, 0.5F, 2); - this.attacker.level.playSound(null, this.attacker, SoundEvents.EVOKER_CAST_SPELL, SoundSource.HOSTILE, 1F, 1F); - this.attacker.level.addFreshEntity(ball); + this.attacker.level().playSound(null, this.attacker, SoundEvents.EVOKER_CAST_SPELL, SoundSource.HOSTILE, 1F, 1F); + this.attacker.level().addFreshEntity(ball); } } @@ -332,20 +333,20 @@ public SummonWispsGoal(EntityHirschgeist parent) { @Override public boolean canUse() { - return this.parent.getTarget() != null && this.parent.getRandom().nextInt(500) == 0 && this.parent.level.getEntitiesOfClass(EntityWisp.class, this.parent.getBoundingBox().inflate(10D), wisp -> wisp.isHirschgeistSummon()).size() == 0; + return this.parent.getTarget() != null && this.parent.getRandom().nextInt(500) == 0 && this.parent.level().getEntitiesOfClass(EntityWisp.class, this.parent.getBoundingBox().inflate(10D), EntityWisp::isHirschgeistSummon).isEmpty(); } @Override public void start() { - if(parent.level instanceof ServerLevel) { - this.parent.level.playSound(null, this.parent, SoundEvents.EVOKER_CAST_SPELL, SoundSource.HOSTILE, 1F, 1F); + if(parent.level() instanceof ServerLevel) { + this.parent.level().playSound(null, this.parent, SoundEvents.EVOKER_CAST_SPELL, SoundSource.HOSTILE, 1F, 1F); for(int i = 0; i < 3; i++) { - EntityWisp wisp = ModEntities.WISP.getEntityType().create((ServerLevel) parent.level, null, null, null, parent.blockPosition().offset(parent.getRandom().nextInt(8) - 4 + 0.5D, parent.getRandom().nextInt(4) + 1 + 0.5D, parent.getRandom().nextInt(8) - 4 + 0.5D), MobSpawnType.REINFORCEMENT, false, false); + EntityWisp wisp = ModEntities.WISP.getEntityType().create((ServerLevel) parent.level(), null, null, parent.blockPosition().offset(Mth.floor(parent.getRandom().nextInt(8) - 4 + 0.5D), Mth.floor(parent.getRandom().nextInt(4) + 1 + 0.5D), Mth.floor(parent.getRandom().nextInt(8) - 4 + 0.5D)), MobSpawnType.REINFORCEMENT, false, false); wisp.setHirschgeistSummon(true); if (parent.getTarget() != null) { wisp.setTarget(parent.getTarget()); } - parent.level.addFreshEntity(wisp); + parent.level().addFreshEntity(wisp); } } } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityMoth.java b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityMoth.java index d041443..0599f00 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityMoth.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityMoth.java @@ -97,7 +97,7 @@ public void tick() { if(Direction.from3DDataValue(this.getLandedInteger()) != Direction.DOWN) { double x = Math.floor(this.getX()) + 0.5D; double z = Math.floor(this.getZ()) + 0.5D; - BlockPos pos = new BlockPos(x, Math.floor(this.getY()) + 0.5D, z); + BlockPos pos = BlockPos.containing(x, Math.floor(this.getY()) + 0.5D, z); BlockPos offset = pos.relative(Direction.from3DDataValue(this.getLandedInteger())); BlockPos diff = pos.subtract(offset); this.teleportTo(x - ((double) diff.getX()) / 2.778D, Math.floor(this.getY()) + 0.5D, z - ((double) diff.getZ()) / 2.778D); @@ -119,15 +119,15 @@ protected void customServerAiStep() { if(this.isLanded()) { Direction d = Direction.from3DDataValue(this.getLandedInteger()); BlockPos offset = blockpos.relative(d); - if(this.level.getBlockState(offset).isFaceSturdy(this.level, offset, d.getOpposite(), SupportType.CENTER)) { - if(this.level.getNearestPlayer(playerPredicate, this) != null || this.getRandom().nextInt(this.isAttractedToLight() ? 500 : 1000) == 0) { + if(this.level().getBlockState(offset).isFaceSturdy(this.level(), offset, d.getOpposite(), SupportType.CENTER)) { + if(this.level().getNearestPlayer(playerPredicate, this) != null || this.getRandom().nextInt(this.isAttractedToLight() ? 500 : 1000) == 0) { this.setNotLanded(); } } else { this.setNotLanded(); } } - if(this.targetPosition == null || this.random.nextInt(30) == 0 || (this.targetPosition.closerThan(this.blockPosition(), 1.0D) && !isLightBlock(level.getBlockState(this.targetPosition)))) { + if(this.targetPosition == null || this.random.nextInt(30) == 0 || (this.targetPosition.closerThan(this.blockPosition(), 1.0D) && !isLightBlock(level().getBlockState(this.targetPosition)))) { int i = 12; int j = 2; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -138,8 +138,8 @@ protected void customServerAiStep() { for(int i1 = 0; i1 <= l; i1 = i1 > 0 ? -i1 : 1 - i1) { for(int j1 = i1 < l && i1 > -l ? l : 0; j1 <= l; j1 = j1 > 0 ? -j1 : 1 - j1) { blockpos$mutableblockpos.set(this.blockPosition()).move(i1, k - 1, j1); - BlockState state = level.getBlockState(blockpos$mutableblockpos); - if(isLightBlock(state) && (destinationBlock == null || state.getLightEmission() >= level.getBlockState(destinationBlock).getLightEmission())) { + BlockState state = level().getBlockState(blockpos$mutableblockpos); + if(isLightBlock(state) && (destinationBlock == null || state.getLightEmission() >= level().getBlockState(destinationBlock).getLightEmission())) { destinationBlock = blockpos$mutableblockpos.immutable(); } } @@ -153,11 +153,11 @@ protected void customServerAiStep() { } else { boolean found = false; if(this.isAttractedToLight()) { - for(LivingEntity entity : level.getEntitiesOfClass(LivingEntity.class, this.getBoundingBox().inflate(10))) { + for(LivingEntity entity : level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox().inflate(10))) { for(InteractionHand hand : InteractionHand.values()) { ItemStack held = entity.getItemInHand(hand); if(held.is(ModTags.Items.MOTH_TARGET_HELD_LIGHT_ITEMS)) { - this.targetPosition = entity.blockPosition().offset(0, 1.5, 0); + this.targetPosition = entity.blockPosition().offset(0, Mth.floor(1.5), 0); found = true; this.setNotLanded(); break; @@ -168,11 +168,11 @@ protected void customServerAiStep() { } } } - if(!found && this.level.getNearestPlayer(playerPredicate, this) == null && this.getRandom().nextInt(this.isAttractedToLight() ? 80 : 30) == 0) { + if(!found && this.level().getNearestPlayer(playerPredicate, this) == null && this.getRandom().nextInt(this.isAttractedToLight() ? 80 : 30) == 0) { for(Direction direction : Direction.values()) { if(direction != Direction.UP) { BlockPos offset = blockpos.relative(direction); - if(level.getBlockState(offset).isFaceSturdy(level, offset, direction.getOpposite(), SupportType.CENTER)) { + if(level().getBlockState(offset).isFaceSturdy(level(), offset, direction.getOpposite(), SupportType.CENTER)) { this.setLanded(direction); this.targetPosition = null; found = true; @@ -182,7 +182,7 @@ protected void customServerAiStep() { } } if(!found) { - this.targetPosition = new BlockPos(this.getX() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5), this.getY() + (double) this.random.nextInt(4) - 1.0D, this.getZ() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5)); + this.targetPosition = BlockPos.containing(this.getX() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5), this.getY() + (double) this.random.nextInt(4) - 1.0D, this.getZ() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5)); } } } @@ -195,7 +195,7 @@ protected void customServerAiStep() { diff = diff.normalize(); for(int i = 1; i < length; ++i) { abb = abb.move(diff); - if (!this.level.noCollision(this, abb)) { + if (!this.level().noCollision(this, abb)) { return false; } } @@ -215,10 +215,10 @@ protected void customServerAiStep() { this.setYRot(this.getYRot() + f1); } int moths_req = getContainer().getCustomConfiguration().getInt("moths_to_destroy_torch"); - if(moths_req != 0 && level.getEntitiesOfClass(EntityMoth.class, this.getBoundingBox()).size() >= moths_req && level.getBlockState(this.blockPosition()).is(ModTags.Blocks.MOTH_BREAKABLE) && ModPlatformEvents.mobGrief(this.level, this)) { - BlockState state = level.getBlockState(this.blockPosition()); - Block.dropResources(state, level, this.blockPosition()); - level.setBlockAndUpdate(this.blockPosition(), Blocks.AIR.defaultBlockState()); + if(moths_req != 0 && level().getEntitiesOfClass(EntityMoth.class, this.getBoundingBox()).size() >= moths_req && level().getBlockState(this.blockPosition()).is(ModTags.Blocks.MOTH_BREAKABLE) && ModPlatformEvents.mobGrief(this.level(), this)) { + BlockState state = level().getBlockState(this.blockPosition()); + Block.dropResources(state, level(), this.blockPosition()); + level().setBlockAndUpdate(this.blockPosition(), Blocks.AIR.defaultBlockState()); } } @@ -246,8 +246,8 @@ private BlockPos tryToFindPositionSlow(Predicate condition) { } public boolean isAttractedToLight() { - long time = this.level.getDayTime() % 24000L; - return level.getBrightness(LightLayer.SKY, this.blockPosition()) < 10 || (time >= 13000L && time <= 23000L); + long time = this.level().getDayTime() % 24000L; + return level().getBrightness(LightLayer.SKY, this.blockPosition()) < 10 || (time >= 13000L && time <= 23000L); } private static boolean isLightBlock(BlockState blockState) { @@ -278,7 +278,7 @@ public boolean hurt(DamageSource source, float amount) { if(this.isInvulnerableTo(source)) { return false; } else { - if(!this.level.isClientSide && this.isLanded()) { + if(!this.level().isClientSide && this.isLanded()) { this.setNotLanded(); } return super.hurt(source, amount); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityWisp.java b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityWisp.java index 819d2c9..850c21a 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityWisp.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityWisp.java @@ -5,6 +5,7 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import dev.itsmeow.imdlib.entity.EntityTypeContainer; import dev.itsmeow.imdlib.entity.interfaces.IContainerEntity; +import dev.itsmeow.whisperwoods.WhisperwoodsMod; import dev.itsmeow.whisperwoods.init.ModEntities; import dev.itsmeow.whisperwoods.item.ItemBlockHirschgeistSkull; import dev.itsmeow.whisperwoods.network.WWNetwork; @@ -16,10 +17,12 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; @@ -28,7 +31,8 @@ import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.EntityDamageSource; +import net.minecraft.world.damagesource.DamageType; +import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.targeting.TargetingConditions; import net.minecraft.world.entity.animal.Animal; @@ -48,7 +52,7 @@ public class EntityWisp extends Animal implements IContainerEntity { - public final DamageSource WISP = new EntityDamageSource("wisp", this).bypassMagic().bypassArmor(); + public static final ResourceKey WISP = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(WhisperwoodsMod.MODID, "wisp")); public boolean isHostile = false; public long lastSpawn = 0; private BlockPos targetPosition; @@ -88,10 +92,10 @@ protected void defineSynchedData() { public void tick() { super.tick(); - if (this.isHostile && level.getDifficulty() == Difficulty.PEACEFUL) { + if (this.isHostile && level().getDifficulty() == Difficulty.PEACEFUL) { this.isHostile = false; this.shouldBeHostile = true; - } else if (this.shouldBeHostile && level.getDifficulty() != Difficulty.PEACEFUL) { + } else if (this.shouldBeHostile && level().getDifficulty() != Difficulty.PEACEFUL) { this.isHostile = true; this.shouldBeHostile = false; } @@ -107,39 +111,39 @@ public void tick() { if(this.getTarget() != null && !HOSTILE_TARGET_PREDICATE.test(this, this.getTarget())) { this.setTarget(null); } - if (!this.level.isClientSide && this.isHirschgeistSummon() && this.getTarget() != null) { + if (!this.level().isClientSide && this.isHirschgeistSummon() && this.getTarget() != null) { double distance = this.distanceTo(this.getTarget()); if (this.attackCooldown <= 0) { if (distance < 10D) { - WWNetwork.HANDLER.sendToPlayers(((ServerChunkCache)this.level.getChunkSource()).chunkMap.entityMap.get(this.getId()).seenBy.stream().map(ServerPlayerConnection::getPlayer).collect(Collectors.toSet()), new WispAttackPacket(this.position().add(0F, this.getBbHeight(), 0F), this.getWispColor().getColor())); - this.getTarget().hurt(DamageSource.MAGIC, 1F); + WWNetwork.HANDLER.sendToPlayers(((ServerChunkCache)this.level().getChunkSource()).chunkMap.entityMap.get(this.getId()).seenBy.stream().map(ServerPlayerConnection::getPlayer).collect(Collectors.toSet()), new WispAttackPacket(this.position().add(0F, this.getBbHeight(), 0F), this.getWispColor().getColor())); + this.getTarget().hurt(this.level().damageSources().magic(), 1F); this.attackCooldown = 40 + this.getRandom().nextInt(6); } } else { this.attackCooldown--; } } - if (state == 400 && !level.isClientSide && level.getServer() != null) { + if (state == 400 && !level().isClientSide && level().getServer() != null) { Player soul = null; if (this.getTarget() instanceof Player) { soul = (Player) this.getTarget(); } if (soul == null) { - soul = level.getServer().getPlayerList().getPlayer(UUID.fromString(this.entityData.get(TARGET_ID))); + soul = level().getServer().getPlayerList().getPlayer(UUID.fromString(this.entityData.get(TARGET_ID))); } if (soul == null) { - soul = level.getServer().getPlayerList().getPlayerByName(this.entityData.get(TARGET_NAME)); + soul = level().getServer().getPlayerList().getPlayerByName(this.entityData.get(TARGET_NAME)); } resetAttackState(); if (soul != null && HOSTILE_TARGET_PREDICATE.test(this, soul)) { - soul.hurt(WISP, 3000F); + soul.hurt(new DamageSource(this.level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(WISP), this), 3000F); } this.targetPosition = null; this.setTarget(null); } - if (this.isPassive() && !level.isClientSide) { - if (level.getEntitiesOfClass(Player.class, this.getBoundingBox().inflate(10)).size() > 0) { - Player nearest = level.getNearestEntity(Player.class, PASSIVE_SCALE_PREDICATE, null, this.getX(), this.getY(), this.getZ(), this.getBoundingBox().inflate(10)); + if (this.isPassive() && !level().isClientSide) { + if (!level().getEntitiesOfClass(Player.class, this.getBoundingBox().inflate(10)).isEmpty()) { + Player nearest = level().getNearestEntity(Player.class, PASSIVE_SCALE_PREDICATE, null, this.getX(), this.getY(), this.getZ(), this.getBoundingBox().inflate(10)); if (nearest != null) { this.entityData.set(PASSIVE_SCALE, nearest.distanceTo(this) / 12F); } else { @@ -153,7 +157,7 @@ public void tick() { @Override public boolean isInvulnerableTo(DamageSource source) { - return super.isInvulnerableTo(source) || source.getEntity() == this || source == DamageSource.MAGIC || source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE || source.getEntity() instanceof EntityHirschgeist; + return super.isInvulnerableTo(source) || source.getEntity() == this || source.is(DamageTypes.MAGIC) || source.is(DamageTypes.IN_FIRE) || source.is(DamageTypes.ON_FIRE) || source.getEntity() instanceof EntityHirschgeist; } public boolean isPassive() { @@ -178,16 +182,16 @@ protected void customServerAiStep() { } if ((this.targetPosition != null && this.blockPosition().distSqr(this.targetPosition) < 4) || this.targetPosition == null || !this.isHostile || !this.hasSoul() || this.isHirschgeistSummon()) { if (this.getTarget() == null && !this.isPassive()) { - this.setTarget(level.getNearestEntity(Player.class, HOSTILE_TARGET_PREDICATE, null, this.getX(), this.getY(), this.getZ(), this.getBoundingBox().inflate(25))); + this.setTarget(level().getNearestEntity(Player.class, HOSTILE_TARGET_PREDICATE, null, this.getX(), this.getY(), this.getZ(), this.getBoundingBox().inflate(25))); } if (!this.isPassive() && this.getTarget() != null) { this.targetPosition = this.getTarget().blockPosition(); } else { - this.targetPosition = new BlockPos(this.getX() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5), this.getY() + (double) this.random.nextInt(4) - 0.1D, this.getZ() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5)); + this.targetPosition = BlockPos.containing(this.getX() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5), this.getY() + (double) this.random.nextInt(4) - 0.1D, this.getZ() + (double) this.random.nextInt(5) - (double) this.random.nextInt(5)); } if (this.hasSoul() && this.isHostile) { - this.targetPosition = new BlockPos(this.getX() + (double) this.random.nextInt(60) - (double) this.random.nextInt(60), this.getY() + (double) this.random.nextInt(4), this.getZ() + (double) this.random.nextInt(60) - (double) this.random.nextInt(60)); + this.targetPosition = BlockPos.containing(this.getX() + (double) this.random.nextInt(60) - (double) this.random.nextInt(60), this.getY() + (double) this.random.nextInt(4), this.getZ() + (double) this.random.nextInt(60) - (double) this.random.nextInt(60)); } } if (targetPosition != null) { @@ -269,8 +273,7 @@ protected void playStepSound(BlockPos pos, BlockState blockIn) { @Override protected void doPush(Entity entity) { - if (entity == this.getTarget() && this.getTarget() != null && entity instanceof Player && HOSTILE_TARGET_PREDICATE.test(this, (Player) entity) && !this.hasSoul() && !this.isHirschgeistSummon()) { - Player player = (Player) entity; + if (entity == this.getTarget() && this.getTarget() != null && entity instanceof Player player && HOSTILE_TARGET_PREDICATE.test(this, (Player) entity) && !this.hasSoul() && !this.isHirschgeistSummon()) { this.entityData.set(ATTACK_STATE, 1); this.entityData.set(TARGET_ID, player.getGameProfile().getId().toString()); this.entityData.set(TARGET_NAME, player.getGameProfile().getName()); @@ -308,7 +311,7 @@ public void readAdditionalSaveData(CompoundTag compound) { @Override public void die(DamageSource cause) { super.die(cause); - if (!level.isClientSide && !this.isBaby()) { + if (!level().isClientSide && !this.isBaby()) { if (this.random.nextInt(10) == 0 || this.hasSoul() || this.isHirschgeistSummon()) { ItemStack stack = new ItemStack(getItemForVariant(this.getEntityData().get(COLOR_VARIANT))); this.spawnAtLocation(stack, 0.5F); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityZotzpyre.java b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityZotzpyre.java index efeb462..77e6459 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityZotzpyre.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/entity/EntityZotzpyre.java @@ -40,8 +40,8 @@ public class EntityZotzpyre extends EntityMonsterWithTypes implements FlyingAnimal { private static final EntityDataAccessor HANGING = SynchedEntityData.defineId(EntityZotzpyre.class, EntityDataSerializers.BOOLEAN); - private FastFlyingMoveControl moveSwoop; - private FlyingMoveControl moveNormal; + protected FastFlyingMoveControl moveSwoop; + protected FlyingMoveControl moveNormal; public EntityZotzpyre(EntityType entityType, Level worldIn) { super(entityType, worldIn); @@ -53,8 +53,8 @@ public EntityZotzpyre(EntityType entityType, Level wor @Override protected void registerGoals() { - this.goalSelector.addGoal(0, new SwoopingAttackGoal(this)); - this.goalSelector.addGoal(1, new HangFromCeilingGoal(this)); + this.goalSelector.addGoal(0, new SwoopingAttackGoal<>(this)); + this.goalSelector.addGoal(1, new HangFromCeilingGoal<>(this)); this.goalSelector.addGoal(2, new WaterAvoidingRandomFlyingGoal(this, 1D)); this.targetSelector.addGoal(0, new HurtByTargetGoal(this)); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, 0, false, false, e -> true)); @@ -115,16 +115,15 @@ public static boolean canSpawn(EntityType type, LevelAccessor wo @Override public boolean doHurtTarget(Entity entityIn) { float f = (float) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue(); - boolean flag = entityIn.hurt(DamageSource.mobAttack(this), f); + boolean flag = entityIn.hurt(this.level().damageSources().mobAttack(this), f); if (flag) { - if(entityIn instanceof Player) { - Player player = (Player) entityIn; + if(entityIn instanceof Player player) { int slowTicks = 0; - if (this.level.getDifficulty() == Difficulty.EASY) { + if (this.level().getDifficulty() == Difficulty.EASY) { slowTicks = 200; // 10s - } else if (this.level.getDifficulty() == Difficulty.NORMAL) { + } else if (this.level().getDifficulty() == Difficulty.NORMAL) { slowTicks = 300; // 15s - } else if (this.level.getDifficulty() == Difficulty.HARD) { + } else if (this.level().getDifficulty() == Difficulty.HARD) { slowTicks = 600; // 30s } if (slowTicks > 0) @@ -162,15 +161,15 @@ public void travel(Vec3 vec3) { this.setDeltaMovement(this.getDeltaMovement().scale(0.5D)); } else { float f = 0.91F; - if (this.onGround) { - f = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ())).getBlock().getFriction() * 0.91F; + if (this.onGround()) { + f = this.level().getBlockState(BlockPos.containing(this.getX(), this.getY() - 1.0D, this.getZ())).getBlock().getFriction() * 0.91F; } float g = 0.16277137F / (f * f * f); - this.moveRelative(this.onGround ? 0.1F * g : 0.02F, vec3); + this.moveRelative(this.onGround() ? 0.1F * g : 0.02F, vec3); this.move(MoverType.SELF, this.getDeltaMovement()); this.setDeltaMovement(this.getDeltaMovement().scale(f)); } - this.calculateEntityAnimation(this, false); + this.calculateEntityAnimation(false); } else { super.travel(vec3); } @@ -202,7 +201,7 @@ public HangFromCeilingGoal(T parentEntity) { @Override public boolean canUse() { - return this.parentEntity.getTarget() == null && this.parentEntity.level.getBlockState(this.parentEntity.blockPosition().above()).isFaceSturdy(this.parentEntity.level, this.parentEntity.blockPosition().above(), Direction.DOWN); + return this.parentEntity.getTarget() == null && this.parentEntity.level().getBlockState(this.parentEntity.blockPosition().above()).isFaceSturdy(this.parentEntity.level(), this.parentEntity.blockPosition().above(), Direction.DOWN); } @Override @@ -228,7 +227,7 @@ public static class SwoopingAttackGoal extends Goal { public enum MovementPhase { SWOOP_TO, HIT, - SWOOP_AWAY; + SWOOP_AWAY } protected MovementPhase phase; @@ -256,8 +255,7 @@ public void stop() { if (this.parentEntity.getMoveControl() instanceof FastFlyingMoveControl) { ((FastFlyingMoveControl) this.parentEntity.getMoveControl()).stop(); } - if(this.parentEntity instanceof EntityZotzpyre) { - EntityZotzpyre zotzpyre = (EntityZotzpyre) this.parentEntity; + if(this.parentEntity instanceof EntityZotzpyre zotzpyre) { zotzpyre.moveControl = zotzpyre.moveNormal; } } @@ -269,8 +267,7 @@ public boolean canUse() { @Override public void start() { - if(this.parentEntity instanceof EntityZotzpyre) { - EntityZotzpyre zotzpyre = (EntityZotzpyre) this.parentEntity; + if(this.parentEntity instanceof EntityZotzpyre zotzpyre) { zotzpyre.moveControl = zotzpyre.moveSwoop; } this.startPos = this.parentEntity.position(); @@ -395,7 +392,7 @@ private boolean canReach(Vec3 vec3, int i) { AABB box = this.mob.getBoundingBox(); for (int j = 1; j < i; ++j) { box = box.move(vec3); - if (this.mob.level.getBlockCollisions(this.mob, box).iterator().hasNext()) { + if (this.mob.level().getBlockCollisions(this.mob, box).iterator().hasNext()) { return false; } } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/entity/projectile/EntityHirschgeistFireball.java b/common/src/main/java/dev/itsmeow/whisperwoods/entity/projectile/EntityHirschgeistFireball.java index fffdb66..a9018b5 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/entity/projectile/EntityHirschgeistFireball.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/entity/projectile/EntityHirschgeistFireball.java @@ -1,8 +1,6 @@ package dev.itsmeow.whisperwoods.entity.projectile; -import dev.architectury.networking.NetworkManager; import dev.itsmeow.whisperwoods.init.ModParticles; -import net.minecraft.network.protocol.Packet; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.AreaEffectCloud; @@ -13,13 +11,10 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import java.util.Random; - public class EntityHirschgeistFireball extends ThrowableProjectile { public LivingEntity thrower; public long lastSpawn; - private Random random = new Random(); public EntityHirschgeistFireball(EntityType entityType, Level worldIn) { super(entityType, worldIn); @@ -30,10 +25,6 @@ public EntityHirschgeistFireball(EntityType this.thrower = throwerIn; } - public Random getRandom() { - return random; - } - public void shoot(double d, double e, double f, float g, float h) { Vec3 vec3 = (new Vec3(d, e, f)).normalize().add(this.random.nextGaussian() * 0.0075D * (double)h, this.random.nextGaussian() * 0.0075D * (double)h, this.random.nextGaussian() * 0.0075D * (double)h).scale(g); this.setDeltaMovement(vec3); @@ -41,24 +32,19 @@ public void shoot(double d, double e, double f, float g, float h) { @Override protected void onHit(HitResult result) { - if (!this.level.isClientSide) { - AreaEffectCloud areaEffectCloud = new AreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ()); + if (!this.level().isClientSide) { + AreaEffectCloud areaEffectCloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); areaEffectCloud.setOwner(this.thrower); areaEffectCloud.setRadius(3.0F); areaEffectCloud.setDuration(2000); areaEffectCloud.setParticle(ModParticles.SOUL_FLAME.get()); areaEffectCloud.addEffect(new MobEffectInstance(MobEffects.HARM)); - this.level.addFreshEntity(areaEffectCloud); - this.level.broadcastEntityEvent(this, (byte) 3); + this.level().addFreshEntity(areaEffectCloud); + this.level().broadcastEntityEvent(this, (byte) 3); this.discard(); } } - @Override - public Packet getAddEntityPacket() { - return NetworkManager.createAddEntityPacket(this); - } - @Override protected void defineSynchedData() {} diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlockEntities.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlockEntities.java index f6758fa..759404f 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlockEntities.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlockEntities.java @@ -6,14 +6,14 @@ import dev.itsmeow.whisperwoods.blockentity.GhostLightBlockEntity; import dev.itsmeow.whisperwoods.blockentity.HGSkullBlockEntity; import dev.itsmeow.whisperwoods.blockentity.HandOfFateBlockEntity; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import java.util.function.Supplier; public class ModBlockEntities { - private static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(WhisperwoodsMod.MODID, Registry.BLOCK_ENTITY_TYPE_REGISTRY); + private static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(WhisperwoodsMod.MODID, Registries.BLOCK_ENTITY_TYPE); public static final RegistrySupplier> GHOST_LIGHT = r("ghost_light_tile", () -> BlockEntityType.Builder.of(GhostLightBlockEntity::new, ModBlocks.GHOST_LIGHT_ELECTRIC_BLUE.get(), ModBlocks.GHOST_LIGHT_FIERY_ORANGE.get(), ModBlocks.GHOST_LIGHT_GOLD.get(), ModBlocks.GHOST_LIGHT_MAGIC_PURPLE.get(), ModBlocks.GHOST_LIGHT_TOXIC_GREEN.get(), ModBlocks.WISP_LANTERN_BLUE.get(), ModBlocks.WISP_LANTERN_GREEN.get(), ModBlocks.WISP_LANTERN_ORANGE.get(), ModBlocks.WISP_LANTERN_PURPLE.get(), ModBlocks.WISP_LANTERN_YELLOW.get()).build(null)); public static final RegistrySupplier> HG_SKULL = r("hirschgeist_skull", () -> BlockEntityType.Builder.of(HGSkullBlockEntity::new, ModBlocks.HIRSCHGEIST_SKULL.get()).build(null)); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlocks.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlocks.java index 8aca099..ef7039d 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlocks.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModBlocks.java @@ -8,17 +8,18 @@ import dev.itsmeow.whisperwoods.block.HirschgeistSkullBlock; import dev.itsmeow.whisperwoods.block.WispLanternBlock; import dev.itsmeow.whisperwoods.util.WispColors; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.material.PushReaction; import java.util.function.Supplier; public class ModBlocks { - private static final DeferredRegister BLOCKS = DeferredRegister.create(WhisperwoodsMod.MODID, Registry.BLOCK_REGISTRY); + private static final DeferredRegister BLOCKS = DeferredRegister.create(WhisperwoodsMod.MODID, Registries.BLOCK); public static RegistrySupplier GHOST_LIGHT_ELECTRIC_BLUE = r("ghost_light_electric_blue", () -> new GhostLightBlock(WispColors.BLUE.getColor())); public static RegistrySupplier GHOST_LIGHT_FIERY_ORANGE = r("ghost_light_fiery_orange", () -> new GhostLightBlock(WispColors.ORANGE.getColor())); @@ -26,13 +27,13 @@ public class ModBlocks { public static RegistrySupplier GHOST_LIGHT_TOXIC_GREEN = r("ghost_light_toxic_green", () -> new GhostLightBlock(WispColors.GREEN.getColor())); public static RegistrySupplier GHOST_LIGHT_MAGIC_PURPLE = r("ghost_light_magic_purple", () -> new GhostLightBlock(WispColors.PURPLE.getColor())); public static RegistrySupplier HIRSCHGEIST_SKULL = r("hirschgeist_skull", HirschgeistSkullBlock::new); - private static final BlockBehaviour.Properties LANTERN_PROPS = BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(3.5F).sound(SoundType.LANTERN).lightLevel(state -> 15).noOcclusion(); + private static final BlockBehaviour.Properties LANTERN_PROPS = BlockBehaviour.Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().strength(3.5F).sound(SoundType.LANTERN).lightLevel(state -> 15).noOcclusion().pushReaction(PushReaction.DESTROY); public static RegistrySupplier WISP_LANTERN_BLUE = r("wisp_lantern_blue", () -> new WispLanternBlock(WispColors.BLUE.getColor(), LANTERN_PROPS)); public static RegistrySupplier WISP_LANTERN_GREEN = r("wisp_lantern_green", () -> new WispLanternBlock(WispColors.GREEN.getColor(), LANTERN_PROPS)); public static RegistrySupplier WISP_LANTERN_ORANGE = r("wisp_lantern_orange", () -> new WispLanternBlock(WispColors.ORANGE.getColor(), LANTERN_PROPS)); public static RegistrySupplier WISP_LANTERN_PURPLE = r("wisp_lantern_purple", () -> new WispLanternBlock(WispColors.PURPLE.getColor(), LANTERN_PROPS)); public static RegistrySupplier WISP_LANTERN_YELLOW = r("wisp_lantern_yellow", () -> new WispLanternBlock(WispColors.YELLOW.getColor(), LANTERN_PROPS)); - public static RegistrySupplier HAND_OF_FATE = r("hand_of_fate", () -> new HandOfFateBlock(BlockBehaviour.Properties.of(Material.METAL).strength(3.0F, 2.0F))); + public static RegistrySupplier HAND_OF_FATE = r("hand_of_fate", () -> new HandOfFateBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).strength(3.0F, 2.0F))); private static RegistrySupplier r(String name, Supplier b) { return BLOCKS.register(name, b); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModCreativeTabs.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModCreativeTabs.java new file mode 100644 index 0000000..e0b4319 --- /dev/null +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModCreativeTabs.java @@ -0,0 +1,44 @@ +package dev.itsmeow.whisperwoods.init; + +import dev.architectury.registry.registries.DeferredRegister; +import dev.architectury.registry.registries.RegistrySupplier; +import dev.itsmeow.whisperwoods.WhisperwoodsMod; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +import java.util.Iterator; + +public class ModCreativeTabs { + + private static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister.create(WhisperwoodsMod.MODID, Registries.CREATIVE_MODE_TAB); + + public static final RegistrySupplier WHISPERWOODS = CREATIVE_MODE_TABS.register("whisperwoods", () -> + CreativeModeTab.builder(CreativeModeTab.Row.TOP, 7) + .title(Component.translatable("itemGroup.whisperwoods.main")) + .icon(() -> new ItemStack(ModItems.GHOST_LIGHT_FIERY_ORANGE.get())) + .displayItems((itemDisplayParameters, output) -> { + for (Iterator> it = ModItems.getTabItems(); it.hasNext(); ) { + RegistrySupplier item = it.next(); + logCreativeTabEntry(item.getId(), item.get()); + output.accept(item.get()); + } + ModEntities.getEntities().values().forEach(cont -> { + logCreativeTabEntry(cont.getEggItem().getId(), cont.getEggItem().get()); + output.accept(new ItemStack(cont.getEggItem().get())); + }); + }).build()); + private static final boolean LOG_CREATIVE_TAB_ENTRIES = false; + + private static void logCreativeTabEntry(ResourceLocation key, Item value) { + if(LOG_CREATIVE_TAB_ENTRIES) + WhisperwoodsMod.LOGGER.info("Registering {} with value {} to whisperwoods tab", key, value); + } + + public static void init() { + CREATIVE_MODE_TABS.register(); + } +} diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModEntities.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModEntities.java index c5f0fbc..30c31a6 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModEntities.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModEntities.java @@ -11,7 +11,7 @@ import dev.itsmeow.whisperwoods.entity.*; import dev.itsmeow.whisperwoods.entity.EntityHidebehind.HidebehindVariant; import dev.itsmeow.whisperwoods.entity.projectile.EntityHirschgeistFireball; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.Difficulty; import net.minecraft.world.entity.EntityType; @@ -50,7 +50,7 @@ public class ModEntities { "owl", "vampire") .biomesOverworld(BiomeTypes.FOREST, BiomeTypes.SWAMP) - .containers("bottled_%s", ItemModEntityContainer.get(WhisperwoodsMod.TAB), "", c -> Items.GLASS_BOTTLE, EntityMoth::bottleTooltip)); + .containers("bottled_%s", ItemModEntityContainer.get(ModCreativeTabs.WHISPERWOODS), "", c -> Items.GLASS_BOTTLE, EntityMoth::bottleTooltip)); public static final EntityTypeContainer HIDEBEHIND = H.add(EntityHidebehind.class, EntityHidebehind::new, "hidebehind", () -> Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20D).add(Attributes.ATTACK_DAMAGE).add(Attributes.ATTACK_DAMAGE, 15D), b -> b .spawn(MobCategory.MONSTER, 8, 1, 1) @@ -83,7 +83,7 @@ public class ModEntities { .add(Attributes.ATTACK_DAMAGE) .add(Attributes.ATTACK_DAMAGE, 6.0D), b -> b .spawn(MobCategory.CREATURE, 2, 1, 1) - .defaultPlacement((t, w, e, p, r) -> w.getEntitiesOfClass(EntityHirschgeist.class, new AABB(p).inflate(300D)).size() == 0) + .defaultPlacement((t, w, e, p, r) -> w.getEntitiesOfClass(EntityHirschgeist.class, new AABB(p).inflate(300D)).isEmpty()) .egg(0xfffff, 0x00000) .size(3F, 4F) .biomesOverworld(BiomeTypes.FOREST)); @@ -113,6 +113,6 @@ public static void init() { } private static RegistrySupplier> projectile(EntityType.EntityFactory factory, String name, float width, float height) { - return IMDLib.getRegistry(Registry.ENTITY_TYPE_REGISTRY).register(new ResourceLocation(WhisperwoodsMod.MODID, name), () -> H.createEntityType(factory, name, MobCategory.MISC, 64, 1, true, width, height)); + return IMDLib.getRegistry(Registries.ENTITY_TYPE).register(new ResourceLocation(WhisperwoodsMod.MODID, name), () -> H.createEntityType(factory, name, MobCategory.MISC, 64, 1, true, width, height)); } } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModItems.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModItems.java index 200b106..253cea0 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModItems.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModItems.java @@ -4,16 +4,17 @@ import dev.architectury.registry.registries.RegistrySupplier; import dev.itsmeow.whisperwoods.WhisperwoodsMod; import dev.itsmeow.whisperwoods.item.ItemBlockHirschgeistSkull; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; +import java.util.*; import java.util.function.Supplier; public class ModItems { - private static final DeferredRegister ITEMS = DeferredRegister.create(WhisperwoodsMod.MODID, Registry.ITEM_REGISTRY); + private static final DeferredRegister ITEMS = DeferredRegister.create(WhisperwoodsMod.MODID, Registries.ITEM); public static RegistrySupplier GHOST_LIGHT_ELECTRIC_BLUE = rIB(ModBlocks.GHOST_LIGHT_ELECTRIC_BLUE); public static RegistrySupplier GHOST_LIGHT_FIERY_ORANGE = rIB(ModBlocks.GHOST_LIGHT_FIERY_ORANGE); @@ -33,7 +34,11 @@ protected static RegistrySupplier r(String name, Supplier } protected static RegistrySupplier rIB(RegistrySupplier parent) { - return ITEMS.register(parent.getId().getPath(), () -> new BlockItem(parent.get(), new Item.Properties().tab(WhisperwoodsMod.TAB))); + return ITEMS.register(parent.getId().getPath(), () -> new BlockItem(parent.get(), new Item.Properties())); + } + + public static Iterator> getTabItems() { + return ITEMS.iterator(); } public static void init() { diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModParticles.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModParticles.java index dffd0c0..698d740 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModParticles.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModParticles.java @@ -5,18 +5,18 @@ import dev.architectury.registry.registries.RegistrySupplier; import dev.itsmeow.whisperwoods.WhisperwoodsMod; import dev.itsmeow.whisperwoods.particle.WispParticleData; -import net.minecraft.core.Registry; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.core.registries.Registries; import java.util.function.Supplier; public class ModParticles { - private static final DeferredRegister> PARTICLES = DeferredRegister.create(WhisperwoodsMod.MODID, Registry.PARTICLE_TYPE_REGISTRY); + private static final DeferredRegister> PARTICLES = DeferredRegister.create(WhisperwoodsMod.MODID, Registries.PARTICLE_TYPE); - public static final RegistrySupplier> WISP = r("wisp", () -> new ParticleType(false, WispParticleData.DESERIALIZER) { + public static final RegistrySupplier> WISP = r("wisp", () -> new ParticleType<>(false, WispParticleData.DESERIALIZER) { @Override public Codec codec() { return WispParticleData.CODEC; diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModSounds.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModSounds.java index bae10cd..deb6026 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModSounds.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModSounds.java @@ -3,15 +3,13 @@ import dev.architectury.registry.registries.DeferredRegister; import dev.architectury.registry.registries.RegistrySupplier; import dev.itsmeow.whisperwoods.WhisperwoodsMod; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; -import java.sql.Ref; - public class ModSounds { - private static final DeferredRegister SOUNDS = DeferredRegister.create(WhisperwoodsMod.MODID, Registry.SOUND_EVENT_REGISTRY); + private static final DeferredRegister SOUNDS = DeferredRegister.create(WhisperwoodsMod.MODID, Registries.SOUND_EVENT); public static final RegistrySupplier HIDEBEHIND_SCARE = r("entity.hidebehind.scare"); public static final RegistrySupplier HIDEBEHIND_AMBIENT = r("entity.hidebehind.ambient"); @@ -22,7 +20,7 @@ public class ModSounds { public static final RegistrySupplier HIRSCHGEIST_DEATH = r("entity.hirschgeist.death"); private static RegistrySupplier r(String name) { - return SOUNDS.register(name, () -> new SoundEvent(new ResourceLocation(WhisperwoodsMod.MODID, name))); + return SOUNDS.register(name, () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(WhisperwoodsMod.MODID, name))); } public static void init() { diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModTags.java b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModTags.java index 7bc0ad5..0852b21 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/init/ModTags.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/init/ModTags.java @@ -1,7 +1,7 @@ package dev.itsmeow.whisperwoods.init; import dev.itsmeow.whisperwoods.WhisperwoodsMod; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; @@ -20,7 +20,7 @@ public static void loadTags() { } private static TagKey tag(String name) { - return TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(WhisperwoodsMod.MODID, name)); + return TagKey.create(Registries.BLOCK, new ResourceLocation(WhisperwoodsMod.MODID, name)); } } @@ -34,7 +34,7 @@ public static void loadTags() { } private static TagKey tag(String name) { - return TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(WhisperwoodsMod.MODID, name)); + return TagKey.create(Registries.ITEM, new ResourceLocation(WhisperwoodsMod.MODID, name)); } } } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockArmor.java b/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockArmor.java index b8c947f..5440470 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockArmor.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockArmor.java @@ -4,14 +4,12 @@ import net.fabricmc.api.Environment; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.core.BlockPos; -import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; import net.minecraft.world.item.context.BlockPlaceContext; @@ -31,8 +29,8 @@ public class ItemBlockArmor extends ArmorItem { private final Block block; - public ItemBlockArmor(Block blockIn, ArmorMaterial materialIn, EquipmentSlot slot, Item.Properties builderIn) { - super(materialIn, slot, builderIn); + public ItemBlockArmor(Block blockIn, ArmorMaterial materialIn, ArmorItem.Type type, Item.Properties builderIn) { + super(materialIn, type, builderIn); this.block = blockIn; } @@ -148,14 +146,6 @@ public String getDescriptionId() { return this.getBlock().getDescriptionId(); } - @Override - public void fillItemCategory(CreativeModeTab group, NonNullList items) { - if(this.allowedIn(group)) { - this.getBlock().fillItemCategory(group, items); - } - - } - @Environment(EnvType.CLIENT) public void appendHoverText(ItemStack stack, Level worldIn, List tooltip, TooltipFlag flagIn) { super.appendHoverText(stack, worldIn, tooltip, flagIn); diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockHirschgeistSkull.java b/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockHirschgeistSkull.java index 1624623..a9edc78 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockHirschgeistSkull.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockHirschgeistSkull.java @@ -20,10 +20,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ArmorMaterial; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; +import net.minecraft.world.item.*; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.Level; @@ -34,7 +31,7 @@ public class ItemBlockHirschgeistSkull extends ItemBlockModeledArmor { public ItemBlockHirschgeistSkull(Block blockIn) { - super(blockIn, HGArmorMaterial.get(), EquipmentSlot.HEAD, new Item.Properties().tab(WhisperwoodsMod.TAB)); + super(blockIn, HGArmorMaterial.get(), Type.HELMET, new Item.Properties()); this.addToBlockToItemMap(Item.BY_BLOCK, this); } @@ -116,7 +113,7 @@ public static class HGArmorMaterial implements ArmorMaterial { private static HGArmorMaterial INSTANCE; - public static final HGArmorMaterial get() { + public static HGArmorMaterial get() { if(INSTANCE == null) { INSTANCE = new HGArmorMaterial(); } @@ -127,13 +124,13 @@ public static final HGArmorMaterial get() { private static final int[] DAMAGE_REDUCTION_AMOUNT_ARRAY = new int[] { 2, 5, 6, 2 }; @Override - public int getDurabilityForSlot(EquipmentSlot slotIn) { - return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * 15; + public int getDurabilityForType(Type type) { + return MAX_DAMAGE_ARRAY[type.getSlot().getIndex()] * 15; } @Override - public int getDefenseForSlot(EquipmentSlot slotIn) { - return DAMAGE_REDUCTION_AMOUNT_ARRAY[slotIn.getIndex()]; + public int getDefenseForType(Type type) { + return DAMAGE_REDUCTION_AMOUNT_ARRAY[type.getSlot().getIndex()]; } @Override diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockModeledArmor.java b/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockModeledArmor.java index a1d9b5f..4d5e908 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockModeledArmor.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/item/ItemBlockModeledArmor.java @@ -13,7 +13,7 @@ public abstract class ItemBlockModeledArmor extends ItemBlockArmor { - public ItemBlockModeledArmor(Block block, ArmorMaterial material, EquipmentSlot slot, Item.Properties properties) { + public ItemBlockModeledArmor(Block block, ArmorMaterial material, ArmorItem.Type slot, Item.Properties properties) { super(block, material, slot, properties); } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/mixin/BlockCollisionsMixin.java b/common/src/main/java/dev/itsmeow/whisperwoods/mixin/BlockCollisionsMixin.java index 4a89e26..61780a4 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/mixin/BlockCollisionsMixin.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/mixin/BlockCollisionsMixin.java @@ -1,6 +1,7 @@ package dev.itsmeow.whisperwoods.mixin; import dev.itsmeow.whisperwoods.util.IOverrideCollisions; +import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockCollisions; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState; @@ -16,19 +17,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import java.util.function.BiFunction; + @Mixin(BlockCollisions.class) -public class BlockCollisionsMixin { +public class BlockCollisionsMixin { @Shadow @Final private CollisionContext context; - @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/BlockGetter;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), method = "computeNext()Lnet/minecraft/world/phys/shapes/VoxelShape;", cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT) - private void computeNext(CallbackInfoReturnable cir, int i, int j, int k, int l, BlockGetter blockGetter, BlockState blockState) { + @Shadow @Final private BiFunction resultProvider; + + @Shadow @Final private BlockPos.MutableBlockPos pos; + + @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/BlockGetter;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), method = "computeNext", cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT) + private void computeNext(CallbackInfoReturnable cir, int i, int j, int k, int l, BlockGetter blockGetter, BlockState blockState) { if(this.context instanceof EntityCollisionContext eContext) { if(eContext.getEntity() instanceof IOverrideCollisions o) { if(o.canPassThrough(blockState)) { - cir.setReturnValue(Shapes.empty()); + cir.setReturnValue(this.resultProvider.apply(this.pos, Shapes.empty())); } } } diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/network/HOFEffectPacket.java b/common/src/main/java/dev/itsmeow/whisperwoods/network/HOFEffectPacket.java index 2c7ebe3..d729b56 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/network/HOFEffectPacket.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/network/HOFEffectPacket.java @@ -1,6 +1,5 @@ package dev.itsmeow.whisperwoods.network; -import com.mojang.math.Vector3f; import dev.architectury.networking.NetworkManager; import dev.architectury.utils.Env; import dev.itsmeow.whisperwoods.particle.WispParticleData; @@ -9,6 +8,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; +import org.joml.Vector3f; import java.util.function.Supplier; @@ -40,7 +40,6 @@ public static HOFEffectPacket decode(FriendlyByteBuf buf) { return new HOFEffectPacket(HOFEffectType.values()[i], new Vector3f(buf.readFloat(), buf.readFloat(), buf.readFloat()), buf.readInt()); } - @SuppressWarnings("resource") public static void handle(HOFEffectPacket msg, Supplier ctx) { if(ctx.get().getEnvironment() == Env.CLIENT) { ctx.get().queue(() -> { diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/network/WispAttackPacket.java b/common/src/main/java/dev/itsmeow/whisperwoods/network/WispAttackPacket.java index 314489b..865a912 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/network/WispAttackPacket.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/network/WispAttackPacket.java @@ -31,7 +31,6 @@ public static WispAttackPacket decode(FriendlyByteBuf buf) { return new WispAttackPacket(new Vec3(buf.readDouble(), buf.readDouble(), buf.readDouble()), buf.readInt()); } - @SuppressWarnings("resource") public static void handle(WispAttackPacket msg, Supplier ctx) { if(ctx.get().getEnvironment() == Env.CLIENT) { ctx.get().queue(() -> { @@ -53,7 +52,7 @@ public static void handle(WispAttackPacket msg, Supplier CODEC = RecordCodecBuilder.create((group) -> { - return group.group(Codec.FLOAT.fieldOf("r").forGetter((in) -> { - return in.getRed(); - }), Codec.FLOAT.fieldOf("g").forGetter((in) -> { - return in.getGreen(); - }), Codec.FLOAT.fieldOf("b").forGetter((in) -> { - return in.getBlue(); - }), Codec.FLOAT.fieldOf("scale").forGetter((in) -> { - return in.getScale(); - })).apply(group, WispParticleData::new); - }); + public static final Codec CODEC = RecordCodecBuilder.create((group) -> group.group( + Codec.FLOAT.fieldOf("r").forGetter(WispParticleData::getRed), + Codec.FLOAT.fieldOf("g").forGetter(WispParticleData::getGreen), + Codec.FLOAT.fieldOf("b").forGetter(WispParticleData::getBlue), + Codec.FLOAT.fieldOf("scale").forGetter(WispParticleData::getScale)).apply(group, WispParticleData::new)); @SuppressWarnings("deprecation") - public static final ParticleOptions.Deserializer DESERIALIZER = new ParticleOptions.Deserializer() { + public static final ParticleOptions.Deserializer DESERIALIZER = new ParticleOptions.Deserializer<>() { public WispParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { reader.expect(' '); float f = (float) reader.readDouble(); @@ -63,9 +57,8 @@ public void writeToNetwork(FriendlyByteBuf buffer) { buffer.writeFloat(this.scale); } - @SuppressWarnings("deprecation") public String writeToString() { - return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getKey(this.getType()), this.red, this.green, this.blue, this.scale); + return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f", BuiltInRegistries.PARTICLE_TYPE.getKey(this.getType()), this.red, this.green, this.blue, this.scale); } public ParticleType getType() { diff --git a/common/src/main/java/dev/itsmeow/whisperwoods/util/IOverrideCollisions.java b/common/src/main/java/dev/itsmeow/whisperwoods/util/IOverrideCollisions.java index 4a33695..cfb94bc 100644 --- a/common/src/main/java/dev/itsmeow/whisperwoods/util/IOverrideCollisions.java +++ b/common/src/main/java/dev/itsmeow/whisperwoods/util/IOverrideCollisions.java @@ -15,10 +15,10 @@ default boolean insideOpaque() { return false; } else { float f = this.getImplementation().getType().getDimensions().width * 0.8F; - AABB aABB = AABB.ofSize(this.getImplementation().getEyePosition(), (double)f, 1.0E-6D, (double)f); + AABB aABB = AABB.ofSize(this.getImplementation().getEyePosition(), f, 1.0E-6D, f); return BlockPos.betweenClosedStream(aABB).anyMatch((blockPos) -> { - BlockState blockState = this.getImplementation().getLevel().getBlockState(blockPos); - return !blockState.isAir() && blockState.isSuffocating(this.getImplementation().getLevel(), blockPos) && !preventSuffocation(blockState) && Shapes.joinIsNotEmpty(blockState.getCollisionShape(this.getImplementation().getLevel(), blockPos).move(blockPos.getX(), blockPos.getY(), blockPos.getZ()), Shapes.create(aABB), BooleanOp.AND); + BlockState blockState = this.getImplementation().level().getBlockState(blockPos); + return !blockState.isAir() && blockState.isSuffocating(this.getImplementation().level(), blockPos) && !preventSuffocation(blockState) && Shapes.joinIsNotEmpty(blockState.getCollisionShape(this.getImplementation().level(), blockPos).move(blockPos.getX(), blockPos.getY(), blockPos.getZ()), Shapes.create(aABB), BooleanOp.AND); }); } } diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_hanging.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_hanging.json index a3ac0ff..53efe23 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_hanging.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_hanging.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_blue" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_blue" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_sitting.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_sitting.json index c4e3216..1bd7808 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_sitting.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_sitting.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_blue" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_blue" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_wall.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_wall.json index 40b0306..18de618 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_wall.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_blue_wall.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_blue" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_blue" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_hanging.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_hanging.json index 15e8084..d46e626 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_hanging.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_hanging.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_green" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_green" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_sitting.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_sitting.json index a504516..5a961ea 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_sitting.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_sitting.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_green" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_green" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_wall.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_wall.json index a3c3f54..92f80ea 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_wall.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_green_wall.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_green" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_green" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_hanging.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_hanging.json index 6de4dcf..aa85365 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_hanging.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_hanging.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_orange" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_orange" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_sitting.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_sitting.json index 0601f76..3be7a49 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_sitting.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_sitting.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_orange" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_orange" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_wall.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_wall.json index a072ed4..46a5e7a 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_wall.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_orange_wall.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_orange" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_orange" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_hanging.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_hanging.json index 5dddb0c..1d47ef0 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_hanging.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_hanging.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_purple" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_purple" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_sitting.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_sitting.json index c673443..69c0ea3 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_sitting.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_sitting.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_purple" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_purple" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_wall.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_wall.json index abd5c75..ce5d2e2 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_wall.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_purple_wall.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_purple" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_purple" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_hanging.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_hanging.json index 7ad685e..b4d07ef 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_hanging.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_hanging.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_yellow" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_yellow" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_sitting.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_sitting.json index 04f7ed6..6de7de6 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_sitting.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_sitting.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_yellow" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_yellow" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_wall.json b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_wall.json index e98e1de..738fb04 100644 --- a/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_wall.json +++ b/common/src/main/resources/assets/whisperwoods/models/block/wisp_lantern_yellow_wall.json @@ -37,8 +37,8 @@ } }, "textures": { - "particle": "whisperwoods:blocks/wisp_lantern", - "lens": "whisperwoods:blocks/wisp_lantern_lens_yellow" + "particle": "whisperwoods:block/wisp_lantern", + "lens": "whisperwoods:block/wisp_lantern_lens_yellow" }, "elements": [ { diff --git a/common/src/main/resources/assets/whisperwoods/models/item/bottled_moth.json b/common/src/main/resources/assets/whisperwoods/models/item/bottled_moth.json index c8d3a57..6b6bec9 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/bottled_moth.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/bottled_moth.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/bottled_moth" + "layer0": "whisperwoods:item/bottled_moth" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_electric_blue.json b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_electric_blue.json index 814a5a7..483fa0c 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_electric_blue.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_electric_blue.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/ghost_light_electric_blue" + "layer0": "whisperwoods:item/ghost_light_electric_blue" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_fiery_orange.json b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_fiery_orange.json index 22125b1..d274fe6 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_fiery_orange.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_fiery_orange.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/ghost_light_fiery_orange" + "layer0": "whisperwoods:item/ghost_light_fiery_orange" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_gold.json b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_gold.json index b855fa6..d3d8ec3 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_gold.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_gold.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/ghost_light_gold" + "layer0": "whisperwoods:item/ghost_light_gold" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_magic_purple.json b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_magic_purple.json index d4a3519..25ca8d0 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_magic_purple.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_magic_purple.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/ghost_light_magic_purple" + "layer0": "whisperwoods:item/ghost_light_magic_purple" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_toxic_green.json b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_toxic_green.json index 3520e7b..2ca88d8 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_toxic_green.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/ghost_light_toxic_green.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/ghost_light_toxic_green" + "layer0": "whisperwoods:item/ghost_light_toxic_green" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/models/item/hand_of_fate.json b/common/src/main/resources/assets/whisperwoods/models/item/hand_of_fate.json index da5ed27..3dda501 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/hand_of_fate.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/hand_of_fate.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/hand_of_fate" + "layer0": "whisperwoods:item/hand_of_fate" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/models/item/hirschgeist_skull.json b/common/src/main/resources/assets/whisperwoods/models/item/hirschgeist_skull.json index 535d5db..e72559b 100644 --- a/common/src/main/resources/assets/whisperwoods/models/item/hirschgeist_skull.json +++ b/common/src/main/resources/assets/whisperwoods/models/item/hirschgeist_skull.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "whisperwoods:items/hirschgeist_skull" + "layer0": "whisperwoods:item/hirschgeist_skull" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/whisperwoods/textures/blocks/hand_of_fate.png b/common/src/main/resources/assets/whisperwoods/textures/block/hand_of_fate.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/blocks/hand_of_fate.png rename to common/src/main/resources/assets/whisperwoods/textures/block/hand_of_fate.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern.png b/common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern.png rename to common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_blue.png b/common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_blue.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_blue.png rename to common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_blue.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_green.png b/common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_green.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_green.png rename to common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_green.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_orange.png b/common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_orange.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_orange.png rename to common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_orange.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_purple.png b/common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_purple.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_purple.png rename to common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_purple.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_yellow.png b/common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_yellow.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/blocks/wisp_lantern_lens_yellow.png rename to common/src/main/resources/assets/whisperwoods/textures/block/wisp_lantern_lens_yellow.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/bottled_moth.png b/common/src/main/resources/assets/whisperwoods/textures/item/bottled_moth.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/bottled_moth.png rename to common/src/main/resources/assets/whisperwoods/textures/item/bottled_moth.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_electric_blue.png b/common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_electric_blue.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_electric_blue.png rename to common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_electric_blue.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_fiery_orange.png b/common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_fiery_orange.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_fiery_orange.png rename to common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_fiery_orange.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_gold.png b/common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_gold.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_gold.png rename to common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_gold.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_magic_purple.png b/common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_magic_purple.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_magic_purple.png rename to common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_magic_purple.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_toxic_green.png b/common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_toxic_green.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/ghost_light_toxic_green.png rename to common/src/main/resources/assets/whisperwoods/textures/item/ghost_light_toxic_green.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/hand_of_fate.png b/common/src/main/resources/assets/whisperwoods/textures/item/hand_of_fate.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/hand_of_fate.png rename to common/src/main/resources/assets/whisperwoods/textures/item/hand_of_fate.png diff --git a/common/src/main/resources/assets/whisperwoods/textures/items/hirschgeist_skull.png b/common/src/main/resources/assets/whisperwoods/textures/item/hirschgeist_skull.png similarity index 100% rename from common/src/main/resources/assets/whisperwoods/textures/items/hirschgeist_skull.png rename to common/src/main/resources/assets/whisperwoods/textures/item/hirschgeist_skull.png diff --git a/common/src/main/resources/data/minecraft/tags/damage_types/bypasses_armor.json b/common/src/main/resources/data/minecraft/tags/damage_types/bypasses_armor.json new file mode 100644 index 0000000..93a1eb8 --- /dev/null +++ b/common/src/main/resources/data/minecraft/tags/damage_types/bypasses_armor.json @@ -0,0 +1,6 @@ +{ + "values": [ + "whisperwoods:hidebehind", + "whisperwoods:wisp" + ] +} \ No newline at end of file diff --git a/common/src/main/resources/data/minecraft/tags/damage_types/bypasses_effects.json b/common/src/main/resources/data/minecraft/tags/damage_types/bypasses_effects.json new file mode 100644 index 0000000..93a1eb8 --- /dev/null +++ b/common/src/main/resources/data/minecraft/tags/damage_types/bypasses_effects.json @@ -0,0 +1,6 @@ +{ + "values": [ + "whisperwoods:hidebehind", + "whisperwoods:wisp" + ] +} \ No newline at end of file diff --git a/common/src/main/resources/data/whisperwoods/damage_type/hidebehind.json b/common/src/main/resources/data/whisperwoods/damage_type/hidebehind.json new file mode 100644 index 0000000..6a64400 --- /dev/null +++ b/common/src/main/resources/data/whisperwoods/damage_type/hidebehind.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "hidebehind", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/common/src/main/resources/data/whisperwoods/damage_type/wisp.json b/common/src/main/resources/data/whisperwoods/damage_type/wisp.json new file mode 100644 index 0000000..5f07194 --- /dev/null +++ b/common/src/main/resources/data/whisperwoods/damage_type/wisp.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "wisp", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/common/src/main/resources/pack.mcmeta b/common/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..ecd9957 --- /dev/null +++ b/common/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Whisperwoods", + "pack_format": 15 + } +} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index 4d8e117..8d797cc 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -26,24 +26,24 @@ dependencies { shadowModImplementation("dev.itsmeow.imdlib:imdlib-fabric:${rootProject.imdlib_version}") { transitive = false } - modRuntimeOnly("com.terraformersmc:modmenu:4.0.4") { + modRuntimeOnly("com.terraformersmc:modmenu:${rootProject.mod_menu_version}") { transitive = false } - modRuntimeOnly ("curse.maven:cloth-config-348521:3871534") { + modRuntimeOnly ("curse.maven:cloth-config-348521:${rootProject.cloth_config_version}") { exclude(group: "net.fabricmc") exclude(group: "net.fabricmc.fabric-api") } - runtimeOnly("me.shedaniel.cloth:basic-math:0.6.1") + runtimeOnly("me.shedaniel.cloth:basic-math:${rootProject.basic_math_version}") } shadowJar { configurations = [project.configurations.shadowCommon, project.configurations.shadowModImplementation] relocate 'dev.itsmeow.imdlib', "${rootProject.maven_group}.imdlib" - classifier "dev-shadow" + archiveClassifier = "dev-shadow" } remapJar { - classifier "remap" + archiveClassifier = "remap" } task fixJar(type: Jar) { @@ -104,7 +104,7 @@ task fixJar(type: Jar) { line -> line.replaceAll('dev/itsmeow/imdlib/mixin/', "dev/itsmeow/${rootProject.mod_id}/imdlib/mixin/") } } - classifier "fabric" + archiveClassifier = "fabric" } sourcesJar.dependsOn fixJar \ No newline at end of file diff --git a/fabric/src/main/java/dev/itsmeow/whisperwoods/client/WhisperwoodsClientFabric.java b/fabric/src/main/java/dev/itsmeow/whisperwoods/client/WhisperwoodsClientFabric.java index ba6c481..fd1258d 100644 --- a/fabric/src/main/java/dev/itsmeow/whisperwoods/client/WhisperwoodsClientFabric.java +++ b/fabric/src/main/java/dev/itsmeow/whisperwoods/client/WhisperwoodsClientFabric.java @@ -8,7 +8,6 @@ import dev.itsmeow.whisperwoods.item.ItemBlockHirschgeistSkull; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderer; -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.minecraft.client.Minecraft; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.particle.ParticleEngine; @@ -22,7 +21,6 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Pose; -import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.item.ItemStack; import java.util.ArrayList; @@ -41,9 +39,8 @@ public void onInitializeClient() { float j = Mth.rotLerp(g, entity.yHeadRotO, entity.yHeadRot); float k = j - h; float o; - if (entity.isPassenger() && entity.getVehicle() instanceof LivingEntity) { - LivingEntity livingEntity2 = (LivingEntity) entity.getVehicle(); - h = Mth.rotLerp(g, livingEntity2.yBodyRotO, livingEntity2.yBodyRot); + if (entity.isPassenger() && entity.getVehicle() instanceof LivingEntity mount) { + h = Mth.rotLerp(g, mount.yBodyRotO, mount.yBodyRot); k = j - h; o = Mth.wrapDegrees(k); if (o < -85.0F) { @@ -75,8 +72,8 @@ public void onInitializeClient() { p = 0.0F; float q = 0.0F; if (!entity.isPassenger() && entity.isAlive()) { - p = Mth.lerp(g, entity.animationSpeedOld, entity.animationSpeed); - q = entity.animationPosition - entity.animationSpeed * (1.0F - g); + p = entity.walkAnimation.speed(g); + q = entity.walkAnimation.position(g); if (entity.isBaby()) { q *= 3.0F; } @@ -89,12 +86,15 @@ public void onInitializeClient() { } model.renderToBuffer(matrices, vertexConsumers.getBuffer(RenderType.entityCutoutNoCull(tex)), light, LivingEntityRenderer.getOverlayCoords(entity, 0.0F), 1F, 1F, 1F, 1F); }, armor); + + /* ClientSpriteRegistryCallback.event(InventoryMenu.BLOCK_ATLAS).register((atlasTexture, registry) -> { registry.register(new ResourceLocation(WhisperwoodsMod.MODID, "particle/flame")); for(int i = 0; i < 6; i++) { registry.register(new ResourceLocation(WhisperwoodsMod.MODID, "particle/wisp_" + i)); } }); + */ ArrayList types = new ArrayList<>(ParticleEngine.RENDER_ORDER); types.add(WispParticle.PARTICLE_SHEET_TRANSLUCENT_114); ParticleEngine.RENDER_ORDER = types; diff --git a/fabric/src/main/java/dev/itsmeow/whisperwoods/fabric/WhisperwoodsModImpl.java b/fabric/src/main/java/dev/itsmeow/whisperwoods/fabric/WhisperwoodsModImpl.java index 15428dd..8dd69e3 100644 --- a/fabric/src/main/java/dev/itsmeow/whisperwoods/fabric/WhisperwoodsModImpl.java +++ b/fabric/src/main/java/dev/itsmeow/whisperwoods/fabric/WhisperwoodsModImpl.java @@ -1,27 +1,4 @@ package dev.itsmeow.whisperwoods.fabric; -import dev.itsmeow.whisperwoods.WhisperwoodsMod; -import dev.itsmeow.whisperwoods.init.ModEntities; -import dev.itsmeow.whisperwoods.init.ModItems; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; -import net.minecraft.core.NonNullList; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; - -import java.util.stream.Collectors; - public class WhisperwoodsModImpl { - public static CreativeModeTab getPlatformTab() { - return FabricItemGroupBuilder.create(new ResourceLocation(WhisperwoodsMod.MODID, "main")) - .icon(() -> new ItemStack(ModItems.GHOST_LIGHT_FIERY_ORANGE.get())) - .appendItems(list -> { - NonNullList tabList = NonNullList.create(); - Registry.ITEM.forEach(item -> item.fillItemCategory(WhisperwoodsMod.TAB, tabList)); - list.addAll(tabList); - list.addAll(ModEntities.getEntities().values().stream().map(cont -> new ItemStack(cont.getEggItem().get())).collect(Collectors.toList())); - }) - .build(); - } } diff --git a/fabric/src/main/java/dev/itsmeow/whisperwoods/mixin/ParticleEngineMixin.java b/fabric/src/main/java/dev/itsmeow/whisperwoods/mixin/ParticleEngineMixin.java index 63d49d3..4564487 100644 --- a/fabric/src/main/java/dev/itsmeow/whisperwoods/mixin/ParticleEngineMixin.java +++ b/fabric/src/main/java/dev/itsmeow/whisperwoods/mixin/ParticleEngineMixin.java @@ -14,11 +14,11 @@ public abstract class ParticleEngineMixin { @Shadow - public abstract void register(ParticleType particleType, ParticleEngine.SpriteParticleRegistration spriteParticleRegistration); + protected abstract void register(ParticleType particleType, ParticleEngine.SpriteParticleRegistration spriteParticleRegistration); @Inject(at = @At("RETURN"), method = "registerProviders()V") private void registerProviders(CallbackInfo callback) { - ClientLifecycleHandler.registerParticles((type, provider) -> this.register(type, (ParticleEngine.SpriteParticleRegistration) spriteSet -> provider.apply(spriteSet))); + ClientLifecycleHandler.registerParticles((type, provider) -> this.register(type, (ParticleEngine.SpriteParticleRegistration) provider::apply)); } } diff --git a/fabric/src/main/resources/assets/minecraft/atlases/blocks.json b/fabric/src/main/resources/assets/minecraft/atlases/blocks.json new file mode 100644 index 0000000..d457991 --- /dev/null +++ b/fabric/src/main/resources/assets/minecraft/atlases/blocks.json @@ -0,0 +1,32 @@ +{ + "sources": [ + { + "type": "single", + "resource": "whisperwoods:particle/flame" + }, + { + "type": "single", + "resource": "whisperwoods:particle/wisp_0" + }, + { + "type": "single", + "resource": "whisperwoods:particle/wisp_1" + }, + { + "type": "single", + "resource": "whisperwoods:particle/wisp_2" + }, + { + "type": "single", + "resource": "whisperwoods:particle/wisp_3" + }, + { + "type": "single", + "resource": "whisperwoods:particle/wisp_4" + }, + { + "type": "single", + "resource": "whisperwoods:particle/wisp_5" + } + ] +} \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index dcd4b0c..62ca45d 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -6,9 +6,9 @@ configurations { } loom { - launches { - all { - arg "-mixin.config", "mixin.imdlib.json" + runs { + configureEach { + programArg("-mixin.config=mixin.imdlib.json") } } forge { @@ -26,13 +26,13 @@ dependencies { shadowJar { configurations = [project.configurations.shadowCommon, project.configurations.shadowModImplementation] relocate 'dev.itsmeow.imdlib', "${rootProject.maven_group}.imdlib" - classifier "dev-shadow" + archiveClassifier = "dev-shadow" exclude "mixin.imdlib-${rootProject.mod_id}.json" exclude "architectury-common.accessWidener" } remapJar { - classifier "remap" + archiveClassifier = "remap" } task fixJar(type: Jar) { @@ -61,7 +61,7 @@ task fixJar(type: Jar) { line -> line.replaceAll('dev/itsmeow/imdlib/mixin/', "dev/itsmeow/${rootProject.mod_id}/imdlib/mixin/") } } - classifier "forge" + archiveClassifier = "forge" } sourcesJar.dependsOn fixJar \ No newline at end of file diff --git a/forge/src/main/java/dev/itsmeow/whisperwoods/client/forge/WhisperwoodsClientForge.java b/forge/src/main/java/dev/itsmeow/whisperwoods/client/forge/WhisperwoodsClientForge.java index cf4d311..f4b0a39 100644 --- a/forge/src/main/java/dev/itsmeow/whisperwoods/client/forge/WhisperwoodsClientForge.java +++ b/forge/src/main/java/dev/itsmeow/whisperwoods/client/forge/WhisperwoodsClientForge.java @@ -18,6 +18,6 @@ public static void clientSetup(FMLClientSetupEvent event) { @SubscribeEvent public static void registerParticleFactory(RegisterParticleProvidersEvent event) { - ClientLifecycleHandler.registerParticles((type, provider) -> event.register(type, (ParticleEngine.SpriteParticleRegistration) spriteSet -> provider.apply(spriteSet))); + ClientLifecycleHandler.registerParticles((type, provider) -> event.registerSpriteSet(type, (ParticleEngine.SpriteParticleRegistration) spriteSet -> provider.apply(spriteSet))); } } diff --git a/forge/src/main/java/dev/itsmeow/whisperwoods/forge/WhisperwoodsModImpl.java b/forge/src/main/java/dev/itsmeow/whisperwoods/forge/WhisperwoodsModImpl.java index ce46ebe..3a0a040 100644 --- a/forge/src/main/java/dev/itsmeow/whisperwoods/forge/WhisperwoodsModImpl.java +++ b/forge/src/main/java/dev/itsmeow/whisperwoods/forge/WhisperwoodsModImpl.java @@ -1,25 +1,4 @@ package dev.itsmeow.whisperwoods.forge; -import dev.itsmeow.whisperwoods.WhisperwoodsMod; -import dev.itsmeow.whisperwoods.init.ModEntities; -import dev.itsmeow.whisperwoods.init.ModItems; -import net.minecraft.core.NonNullList; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; - public class WhisperwoodsModImpl { - public static CreativeModeTab getPlatformTab() { - return new CreativeModeTab(WhisperwoodsMod.MODID + ".main") { - @Override - public ItemStack makeIcon() { - return new ItemStack(ModItems.GHOST_LIGHT_FIERY_ORANGE.get()); - } - - @Override - public void fillItemList(NonNullList toDisplay) { - super.fillItemList(toDisplay); - ModEntities.getEntities().values().forEach(cont -> toDisplay.add(new ItemStack(cont.getEggItem().get()))); - } - }; - } } diff --git a/forge/src/main/java/dev/itsmeow/whisperwoods/mixin/forge/ItemBlockModeledArmorMixin.java b/forge/src/main/java/dev/itsmeow/whisperwoods/mixin/forge/ItemBlockModeledArmorMixin.java index 4544bc8..de993b2 100644 --- a/forge/src/main/java/dev/itsmeow/whisperwoods/mixin/forge/ItemBlockModeledArmorMixin.java +++ b/forge/src/main/java/dev/itsmeow/whisperwoods/mixin/forge/ItemBlockModeledArmorMixin.java @@ -16,7 +16,7 @@ @Mixin(ItemBlockModeledArmor.class) public abstract class ItemBlockModeledArmorMixin extends ArmorItem { - public ItemBlockModeledArmorMixin(ArmorMaterial arg, EquipmentSlot arg2, Properties arg3) { + public ItemBlockModeledArmorMixin(ArmorMaterial arg, ArmorItem.Type arg2, Properties arg3) { super(arg, arg2, arg3); } diff --git a/gradle.properties b/gradle.properties index 97985cc..8cd9b53 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,18 @@ maven_group = dev.itsmeow.whisperwoods # Forge - mc_version = 1.19 - forge_version = 41.0.100 - architectury_version = 5.9.31 - fabric_loader_version = 0.14.7 - fabric_api_version = 0.57.0+1.19 - imdlib_version = 1.19-f00da719bc3b557d294420e37e9c843774559754 + mc_version = 1.20.1 + forge_version = 47.2.30 + architectury_version = 9.2.14 + fabric_loader_version = 0.15.10 + fabric_api_version = 0.92.1+1.20.1 + imdlib_version = 1.20.1-3eeca9fb6b161ac6e5c6fbd3e27033c6d0558692 + +# Fabric + mod_menu_version = 7.2.2 + # 11.1.118 + cloth_config_version = 4973440 + basic_math_version = 0.6.1 # Publishing github = itsmeow/whisperwoods @@ -23,7 +29,7 @@ curse_relations_forge = architectury-api:requiredDependency # Toolchain Versions - loom_version = 0.12.0-SNAPSHOT + loom_version = 1.7-SNAPSHOT architectury_plugin_version = 3.4-SNAPSHOT # Misc diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6b7fd26..dab2a01 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +zipStorePath=wrapper/dists \ No newline at end of file