DRYING_RACK_BLOCK_ENTITY;
- /**
- * registers the {@link Block} along with a {@link BlockItem} in the provided {@link ItemGroup}
- */
- private static B register(String name, B block, ItemGroup tab) {
- Item.Settings settings = new Item.Settings();
- if (tab != null) {
- settings.group(tab);
- }
- return register(name, block, new BlockItem(block, settings));
- }
+ static {
+ WHALE_MEAT_BLOCK = register("whale_meat_block", new WhaleMeatBlock(QuiltBlockSettings.of(Material.ORGANIC_PRODUCT).requiresTool().sounds(BlockSoundGroup.HONEY).strength(1.0F, 1.0F)), ItemGroup.BREWING);
+ BLUEBERRY_BUSH = register("blueberry_bush", new BlueberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH)));
+ CLOUDBERRY_BUSH = register("cloudberry_bush", new CloudberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH)));
+ RASPBERRY_BUSH = register("raspberry_bush", new RaspberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH)));
+ SALMONBERRY_BUSH = register("salmonberry_bush", new SalmonberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH)));
+ LABRADOR_TEA = register("labrador_tea", new LabradorTeaBlock(StatusEffects.REGENERATION, 12, AbstractBlock.Settings.of(Material.PLANT).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS)));
+ DRIFTWOOD_LOG = register("driftwood_log", new PillarBlock(QuiltBlockSettings.copyOf(Blocks.OAK_LOG)), ItemGroup.BUILDING_BLOCKS);
+ DRYING_RACK = register("drying_rack", new DryingRackBlock(QuiltBlockSettings.copyOf(Blocks.OAK_FENCE)), ItemGroup.DECORATIONS);
+ DRYING_RACK_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying_rack"), QuiltBlockEntityTypeBuilder.create(DryingRackBlockEntity::new, DRYING_RACK).build(null));
+ }
- /**
- * registers the {@link Block} along with the provided {@link BlockItem}
- */
- private static B register(String name, B block, BlockItem item) {
- register(name, block);
- if (item != null) {
- item.appendBlocks(Item.BLOCK_ITEMS, item);
- Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item);
- }
- return block;
- }
+ /**
+ * Registers the {@link Block} along with a {@link BlockItem} in the provided {@link ItemGroup}.
+ */
+ private static B register(String name, B block, ItemGroup tab) {
+ Item.Settings settings = new Item.Settings();
+ if (tab != null) {
+ settings.group(tab);
+ }
- /**
- * registers the {@link Block}
- */
- private static B register(String name, B block) {
- Registry.register(Registry.BLOCK, new Identifier(AlaskaNativeCraft.MOD_ID, name), block);
- return block;
- }
+ return register(name, block, new BlockItem(block, settings));
+ }
- public static void register() {
- addFuels();
- addFlammables();
- }
+ /**
+ * Registers the {@link Block} along with the provided {@link BlockItem}.
+ */
+ private static B register(String name, B block, BlockItem item) {
+ register(name, block);
+ if (item != null) {
+ item.appendBlocks(Item.BLOCK_ITEMS, item);
+ Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item);
+ }
- private static void addFuels() {
- FuelRegistry fuelRegistry = FuelRegistry.INSTANCE;
- fuelRegistry.add(WHALE_MEAT_BLOCK, 800);
- fuelRegistry.add(DRYING_RACK, 300);
- }
+ return block;
+ }
- private static void addFlammables() {
- FlammableBlockRegistry flammableRegistry = FlammableBlockRegistry.getDefaultInstance();
- flammableRegistry.add(WHALE_MEAT_BLOCK, 60, 100);
- flammableRegistry.add(DRIFTWOOD_LOG, 5, 5);
- flammableRegistry.add(DRYING_RACK, 5, 5);
- flammableRegistry.add(BLUEBERRY_BUSH, 60, 100);
- flammableRegistry.add(CLOUDBERRY_BUSH, 60, 100);
- flammableRegistry.add(RASPBERRY_BUSH, 60, 100);
- flammableRegistry.add(SALMONBERRY_BUSH, 60, 100);
- flammableRegistry.add(LABRADOR_TEA, 60, 100);
- }
+ /**
+ * Registers the {@link Block}.
+ */
+ private static B register(String name, B block) {
+ Registry.register(Registry.BLOCK, new Identifier(AlaskaNativeCraft.MOD_ID, name), block);
+ return block;
+ }
+ public static void register() {
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java
index b4fd895e..f6d61cae 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java
@@ -1,18 +1,19 @@
package com.github.platymemo.alaskanativecraft.block;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
+
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
public class BlueberryBushBlock extends BushBlock {
- public BlueberryBushBlock(Settings settings) {
- super(settings);
- }
+ public BlueberryBushBlock(Settings settings) {
+ super(settings);
+ }
- @Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
- return AlaskaItems.BLUEBERRIES.getDefaultStack();
- }
+ @Override
+ public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ return AlaskaItems.BLUEBERRIES.getDefaultStack();
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java
index e726e142..7df714be 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java
@@ -1,5 +1,7 @@
package com.github.platymemo.alaskanativecraft.block;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.block.BlockState;
import net.minecraft.block.SweetBerryBushBlock;
import net.minecraft.entity.Entity;
@@ -17,41 +19,41 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
/**
- * base class for berry bushes,
- * contains common code for berry harvesting and entity collision
- *
when creating a new bush, always override {@link #getPickStack(BlockView, BlockPos, BlockState)} to associate the bush to a berry item
+ * Base class for berry bushes.
+ * Contains common code for berry harvesting and entity collision.
+ *
+ * When creating a new bush, always override {@link #getPickStack(BlockView, BlockPos, BlockState)} to associate the bush to a berry item
*
* @author Platymemo, ix0rai
*/
public class BushBlock extends SweetBerryBushBlock {
- public BushBlock(Settings settings) {
- super(settings);
- }
+ public BushBlock(Settings settings) {
+ super(settings);
+ }
- @Override
- public ActionResult onUse(@NotNull BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
- int i = state.get(AGE);
- boolean bl = i == 3;
- if (!bl && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
- return ActionResult.PASS;
- } else if (i > 1) {
- int j = 1 + world.random.nextInt(2);
- dropStack(world, pos, new ItemStack(this.getPickStack(world, pos, state).getItem(), j + (bl ? 1 : 0)));
- world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F);
- world.setBlockState(pos, state.with(AGE, 1), 2);
- return ActionResult.success(world.isClient);
- } else {
- return ActionResult.PASS;
- }
- }
+ @Override
+ public ActionResult onUse(@NotNull BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
+ int i = state.get(AGE);
+ boolean bl = i == 3;
+ if (!bl && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
+ return ActionResult.PASS;
+ } else if (i > 1) {
+ int j = 1 + world.random.nextInt(2);
+ dropStack(world, pos, new ItemStack(this.getPickStack(world, pos, state).getItem(), j + (bl ? 1 : 0)));
+ world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F);
+ world.setBlockState(pos, state.with(AGE, 1), 2);
+ return ActionResult.success(world.isClient);
+ } else {
+ return ActionResult.PASS;
+ }
+ }
- @Override
- public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
- if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) {
- entity.slowMovement(state, new Vec3d(1.0D, 0.90D, 1.0D));
- }
- }
+ @Override
+ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
+ if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) {
+ entity.slowMovement(state, new Vec3d(1.0D, 0.90D, 1.0D));
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java
index df7271ae..f1ca3807 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java
@@ -1,6 +1,8 @@
package com.github.platymemo.alaskanativecraft.block;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
@@ -8,34 +10,33 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
-import org.jetbrains.annotations.NotNull;
public class CloudberryBushBlock extends BushBlock {
- private static final VoxelShape MID_SHAPE;
- private static final VoxelShape FULL_SHAPE;
+ private static final VoxelShape MID_SHAPE;
+ private static final VoxelShape FULL_SHAPE;
- static {
- MID_SHAPE = Block.createCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 9.0D, 15.0D);
- FULL_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D);
- }
+ static {
+ MID_SHAPE = Block.createCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 9.0D, 15.0D);
+ FULL_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D);
+ }
- public CloudberryBushBlock(Settings settings) {
- super(settings);
- }
+ public CloudberryBushBlock(Settings settings) {
+ super(settings);
+ }
- @Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
- return AlaskaItems.CLOUDBERRIES.getDefaultStack();
- }
+ @Override
+ public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ return AlaskaItems.CLOUDBERRIES.getDefaultStack();
+ }
- @Override
- public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
- if (state.get(AGE) > 0 && state.get(AGE) < 3) {
- return MID_SHAPE;
- } else if (state.get(AGE) == 3) {
- return FULL_SHAPE;
- } else {
- return super.getOutlineShape(state, world, pos, context);
- }
- }
+ @Override
+ public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
+ if (state.get(AGE) > 0 && state.get(AGE) < 3) {
+ return MID_SHAPE;
+ } else if (state.get(AGE) == 3) {
+ return FULL_SHAPE;
+ } else {
+ return super.getOutlineShape(state, world, pos, context);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java
index af1f7037..9c972c78 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java
@@ -1,8 +1,18 @@
package com.github.platymemo.alaskanativecraft.block;
+import java.util.Optional;
+
import com.github.platymemo.alaskanativecraft.block.entity.DryingRackBlockEntity;
import com.github.platymemo.alaskanativecraft.recipe.DryingRecipe;
-import net.minecraft.block.*;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockRenderType;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.BlockWithEntity;
+import net.minecraft.block.ShapeContext;
+import net.minecraft.block.Waterloggable;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
@@ -28,183 +38,182 @@
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Optional;
@SuppressWarnings("deprecation")
public class DryingRackBlock extends BlockWithEntity implements Waterloggable {
- public static final BooleanProperty WATERLOGGED;
- public static final BooleanProperty CONNECTED_POS;
- public static final BooleanProperty CONNECTED_NEG;
- public static final EnumProperty AXIS;
- private static final VoxelShape X_SHAPE = Block.createCuboidShape(0, 0, 6, 16, 8, 10);
- private static final VoxelShape Z_SHAPE = Block.createCuboidShape(6, 0, 0, 10, 8, 16);
-
- static {
- WATERLOGGED = Properties.WATERLOGGED;
- CONNECTED_POS = BooleanProperty.of("positive");
- CONNECTED_NEG = BooleanProperty.of("negative");
- AXIS = EnumProperty.of("axis", Direction.Axis.class, Direction.Axis::isHorizontal);
- }
-
- public DryingRackBlock(Settings settings) {
- super(settings);
- this.setDefaultState(this.getStateManager().getDefaultState()
- .with(WATERLOGGED, false)
- .with(CONNECTED_POS, false)
- .with(CONNECTED_NEG, false)
- .with(AXIS, Direction.Axis.Z));
- }
-
- @Override
- public ActionResult onUse(BlockState state, @NotNull World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
- BlockEntity blockEntity = world.getBlockEntity(pos);
- if (!world.isClient && blockEntity instanceof DryingRackBlockEntity dryingRackBlockEntity) {
- ItemStack itemStack = player.getStackInHand(hand);
- Optional optional = dryingRackBlockEntity.getRecipeFor(itemStack);
- if (optional.isPresent()) {
- if (dryingRackBlockEntity.addItem(player.getAbilities().creativeMode ? itemStack.copy() : itemStack, (optional.get()).getCookTime())) {
- // TODO Drying rack interaction stats
- return ActionResult.SUCCESS;
- }
- return ActionResult.CONSUME;
- } else {
- ItemStack dryingRackItem = dryingRackBlockEntity.getDriedItem();
- ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), dryingRackItem);
- return ActionResult.SUCCESS;
- }
- }
- return ActionResult.SUCCESS;
- }
-
- @Override
- public void onStateReplaced(@NotNull BlockState state, World world, BlockPos pos, @NotNull BlockState newState, boolean moved) {
- if (!state.isOf(newState.getBlock())) {
- BlockEntity blockEntity = world.getBlockEntity(pos);
- if (blockEntity instanceof DryingRackBlockEntity) {
- ItemScatterer.spawn(world, pos, ((DryingRackBlockEntity) blockEntity).getItemsBeingDried());
- }
-
- super.onStateReplaced(state, world, pos, newState, moved);
- }
- }
-
- @Override
- public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
- if (state.get(AXIS) == Direction.Axis.X) {
- return X_SHAPE;
- } else {
- return Z_SHAPE;
- }
- }
-
- @Nullable
- @Override
- public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) {
- boolean bl = ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER;
- World world = ctx.getWorld();
- BlockPos blockPos = ctx.getBlockPos();
-
- BlockState state = this.getDefaultState();
-
- Direction direction = ctx.getPlayerFacing();
- Direction.Axis axis = direction.getAxis() == Direction.Axis.X ? Direction.Axis.Z : Direction.Axis.X;
- Direction left = Direction.get(Direction.AxisDirection.NEGATIVE, axis);
- Direction right = Direction.get(Direction.AxisDirection.POSITIVE, axis);
- return state.with(AXIS, axis)
- .with(CONNECTED_NEG, this.canConnect(left, world.getBlockState(blockPos.offset(left))))
- .with(CONNECTED_POS, this.canConnect(right, world.getBlockState(blockPos.offset(right))))
- .with(WATERLOGGED, bl);
- }
-
- @Override
- public BlockState rotate(@NotNull BlockState state, BlockRotation rotation) {
- return switch (rotation) {
- case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) {
- case X -> state.with(AXIS, Direction.Axis.Z);
- case Z -> state.with(AXIS, Direction.Axis.X);
- default -> state;
- };
- default -> state;
- };
- }
-
- private boolean canConnect(Direction direction, @NotNull BlockState otherState) {
- if (otherState.isIn(BlockTags.LOGS) || otherState.isIn(BlockTags.WALLS) || otherState.isIn(BlockTags.FENCES) || otherState.isIn(BlockTags.FENCE_GATES)) {
- return true;
- } else if (otherState.isOf(this)) {
- return otherState.get(AXIS) == direction.getAxis();
- } else {
- return false;
- }
- }
-
- @Override
- public BlockState getStateForNeighborUpdate(@NotNull BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
- if (state.get(WATERLOGGED)) {
- world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
- }
-
- return state.get(AXIS) == direction.getAxis() ?
- state.with(direction.getDirection() == Direction.AxisDirection.POSITIVE ? CONNECTED_POS : CONNECTED_NEG, this.canConnect(direction, newState))
- : super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
- }
-
- @Override
- public BlockRenderType getRenderType(BlockState state) {
- return BlockRenderType.MODEL;
- }
-
- @Override
- public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, @NotNull BlockState state, FluidState fluidState) {
- if (!(Boolean) state.get(Properties.WATERLOGGED) && fluidState.getFluid() == Fluids.WATER) {
- BlockEntity blockEntity = world.getBlockEntity(pos);
- if (blockEntity instanceof DryingRackBlockEntity) {
- ((DryingRackBlockEntity) blockEntity).spawnItemsBeingDried();
- }
-
- world.setBlockState(pos, state.with(WATERLOGGED, true), 3);
- world.createAndScheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world));
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public FluidState getFluidState(@NotNull BlockState state) {
- return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
- }
-
- @Override
- public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
- return false;
- }
-
- @Nullable
- @Override
- public BlockEntityTicker getTicker(@NotNull World world, BlockState state, BlockEntityType type) {
- if (!world.isClient) {
- if (state.get(WATERLOGGED) || world.isRaining()) {
- return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::possiblyWetTick);
- } else {
- return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::updateItemsBeingDried);
- }
- }
- return null;
- }
-
- @Nullable
- @Override
- public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
- return new DryingRackBlockEntity(pos, state);
- }
-
- @Override
- protected void appendProperties(StateManager.Builder builder) {
- super.appendProperties(builder);
- builder.add(WATERLOGGED).add(CONNECTED_POS).add(CONNECTED_NEG).add(AXIS);
- }
+ public static final BooleanProperty WATERLOGGED;
+ public static final BooleanProperty CONNECTED_POS;
+ public static final BooleanProperty CONNECTED_NEG;
+ public static final EnumProperty AXIS;
+ private static final VoxelShape X_SHAPE = Block.createCuboidShape(0, 0, 6, 16, 8, 10);
+ private static final VoxelShape Z_SHAPE = Block.createCuboidShape(6, 0, 0, 10, 8, 16);
+
+ static {
+ WATERLOGGED = Properties.WATERLOGGED;
+ CONNECTED_POS = BooleanProperty.of("positive");
+ CONNECTED_NEG = BooleanProperty.of("negative");
+ AXIS = EnumProperty.of("axis", Direction.Axis.class, Direction.Axis::isHorizontal);
+ }
+
+ public DryingRackBlock(Settings settings) {
+ super(settings);
+ this.setDefaultState(this.getStateManager().getDefaultState()
+ .with(WATERLOGGED, false)
+ .with(CONNECTED_POS, false)
+ .with(CONNECTED_NEG, false)
+ .with(AXIS, Direction.Axis.Z));
+ }
+
+ @Override
+ public ActionResult onUse(BlockState state, @NotNull World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
+ BlockEntity blockEntity = world.getBlockEntity(pos);
+ if (!world.isClient && blockEntity instanceof DryingRackBlockEntity dryingRackBlockEntity) {
+ ItemStack itemStack = player.getStackInHand(hand);
+ Optional optional = dryingRackBlockEntity.getRecipeFor(itemStack);
+ if (optional.isPresent()) {
+ if (dryingRackBlockEntity.addItem(player.getAbilities().creativeMode ? itemStack.copy() : itemStack, (optional.get()).getCookTime())) {
+ // TODO Drying rack interaction stats
+ return ActionResult.SUCCESS;
+ }
+
+ return ActionResult.CONSUME;
+ } else {
+ ItemStack dryingRackItem = dryingRackBlockEntity.getDriedItem();
+ ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), dryingRackItem);
+ return ActionResult.SUCCESS;
+ }
+ }
+
+ return ActionResult.SUCCESS;
+ }
+
+ @Override
+ public void onStateReplaced(@NotNull BlockState state, World world, BlockPos pos, @NotNull BlockState newState, boolean moved) {
+ if (!state.isOf(newState.getBlock())) {
+ BlockEntity blockEntity = world.getBlockEntity(pos);
+ if (blockEntity instanceof DryingRackBlockEntity) {
+ ItemScatterer.spawn(world, pos, ((DryingRackBlockEntity) blockEntity).getItemsBeingDried());
+ }
+
+ super.onStateReplaced(state, world, pos, newState, moved);
+ }
+ }
+
+ @Override
+ public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
+ if (state.get(AXIS) == Direction.Axis.X) {
+ return X_SHAPE;
+ } else {
+ return Z_SHAPE;
+ }
+ }
+
+ @Nullable
+ @Override
+ public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) {
+ boolean bl = ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER;
+ World world = ctx.getWorld();
+ BlockPos blockPos = ctx.getBlockPos();
+
+ BlockState state = this.getDefaultState();
+
+ Direction direction = ctx.getPlayerFacing();
+ Direction.Axis axis = direction.getAxis() == Direction.Axis.X ? Direction.Axis.Z : Direction.Axis.X;
+ Direction left = Direction.get(Direction.AxisDirection.NEGATIVE, axis);
+ Direction right = Direction.get(Direction.AxisDirection.POSITIVE, axis);
+ return state.with(AXIS, axis)
+ .with(CONNECTED_NEG, this.canConnect(left, world.getBlockState(blockPos.offset(left))))
+ .with(CONNECTED_POS, this.canConnect(right, world.getBlockState(blockPos.offset(right))))
+ .with(WATERLOGGED, bl);
+ }
+
+ @Override
+ public BlockState rotate(@NotNull BlockState state, BlockRotation rotation) {
+ return switch (rotation) {
+ case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) {
+ case X -> state.with(AXIS, Direction.Axis.Z);
+ case Z -> state.with(AXIS, Direction.Axis.X);
+ default -> state;
+ };
+ default -> state;
+ };
+ }
+
+ private boolean canConnect(Direction direction, @NotNull BlockState otherState) {
+ if (otherState.isIn(BlockTags.LOGS) || otherState.isIn(BlockTags.WALLS) || otherState.isIn(BlockTags.FENCES) || otherState.isIn(BlockTags.FENCE_GATES)) {
+ return true;
+ } else if (otherState.isOf(this)) {
+ return otherState.get(AXIS) == direction.getAxis();
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public BlockState getStateForNeighborUpdate(@NotNull BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
+ if (state.get(WATERLOGGED)) {
+ world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
+ }
+
+ return state.get(AXIS) == direction.getAxis()
+ ? state.with(direction.getDirection() == Direction.AxisDirection.POSITIVE ? CONNECTED_POS : CONNECTED_NEG, this.canConnect(direction, newState))
+ : super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
+ }
+
+ @Override
+ public BlockRenderType getRenderType(BlockState state) {
+ return BlockRenderType.MODEL;
+ }
+
+ @Override
+ public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, @NotNull BlockState state, FluidState fluidState) {
+ if (!(Boolean) state.get(Properties.WATERLOGGED) && fluidState.getFluid() == Fluids.WATER) {
+ BlockEntity blockEntity = world.getBlockEntity(pos);
+ if (blockEntity instanceof DryingRackBlockEntity) {
+ ((DryingRackBlockEntity) blockEntity).spawnItemsBeingDried();
+ }
+
+ world.setBlockState(pos, state.with(WATERLOGGED, true), 3);
+ world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world));
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public FluidState getFluidState(@NotNull BlockState state) {
+ return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
+ }
+
+ @Override
+ public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
+ return false;
+ }
+
+ @Nullable
+ @Override
+ public BlockEntityTicker getTicker(@NotNull World world, BlockState state, BlockEntityType type) {
+ if (!world.isClient) {
+ if (state.get(WATERLOGGED) || world.isRaining()) {
+ return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::possiblyWetTick);
+ } else {
+ return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::updateItemsBeingDried);
+ }
+ }
+
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
+ return new DryingRackBlockEntity(pos, state);
+ }
+
+ @Override
+ protected void appendProperties(StateManager.Builder builder) {
+ super.appendProperties(builder);
+ builder.add(WATERLOGGED).add(CONNECTED_POS).add(CONNECTED_NEG).add(AXIS);
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java
index d363ced2..031c243a 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java
@@ -1,37 +1,41 @@
package com.github.platymemo.alaskanativecraft.block;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
-import net.minecraft.block.*;
+
+import net.minecraft.block.AbstractBlock;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.Fertilizable;
+import net.minecraft.block.FlowerBlock;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.random.Random;
+import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class LabradorTeaBlock extends FlowerBlock implements Fertilizable {
- public LabradorTeaBlock(StatusEffect suspiciousStewEffect, int effectDuration, AbstractBlock.Settings settings) {
- super(suspiciousStewEffect, effectDuration, settings);
- }
+ public LabradorTeaBlock(StatusEffect suspiciousStewEffect, int effectDuration, AbstractBlock.Settings settings) {
+ super(suspiciousStewEffect, effectDuration, settings);
+ }
- @Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
- return AlaskaItems.LABRADOR_TEA.getDefaultStack();
- }
+ @Override
+ public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ return AlaskaItems.LABRADOR_TEA.getDefaultStack();
+ }
- @Override
- public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
- return true;
- }
+ @Override
+ public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
+ return true;
+ }
- @Override
- public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
- return true;
- }
+ @Override
+ public boolean canGrow(World world, RandomGenerator random, BlockPos pos, BlockState state) {
+ return true;
+ }
- @Override
- public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
- dropStack(world, pos, new ItemStack(this));
- }
+ @Override
+ public void grow(ServerWorld world, RandomGenerator random, BlockPos pos, BlockState state) {
+ dropStack(world, pos, new ItemStack(this));
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java
index 643ae6f3..ad291e3c 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java
@@ -1,18 +1,19 @@
package com.github.platymemo.alaskanativecraft.block;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
+
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
public class RaspberryBushBlock extends BushBlock {
- public RaspberryBushBlock(Settings settings) {
- super(settings);
- }
+ public RaspberryBushBlock(Settings settings) {
+ super(settings);
+ }
- @Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
- return AlaskaItems.RASPBERRIES.getDefaultStack();
- }
+ @Override
+ public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ return AlaskaItems.RASPBERRIES.getDefaultStack();
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java
index 0a037367..c74fd20a 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java
@@ -1,18 +1,19 @@
package com.github.platymemo.alaskanativecraft.block;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
+
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
public class SalmonberryBushBlock extends BushBlock {
- public SalmonberryBushBlock(Settings settings) {
- super(settings);
- }
+ public SalmonberryBushBlock(Settings settings) {
+ super(settings);
+ }
- @Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
- return AlaskaItems.SALMONBERRIES.getDefaultStack();
- }
+ @Override
+ public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ return AlaskaItems.SALMONBERRIES.getDefaultStack();
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java
index b15ae83c..157d149b 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java
@@ -1,5 +1,7 @@
package com.github.platymemo.alaskanativecraft.block;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@@ -7,22 +9,20 @@
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.util.math.Direction;
-import org.jetbrains.annotations.NotNull;
public class WhaleMeatBlock extends FacingBlock {
+ public WhaleMeatBlock(AbstractBlock.Settings settings) {
+ super(settings);
+ this.setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH));
+ }
- public WhaleMeatBlock(AbstractBlock.Settings settings) {
- super(settings);
- this.setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH));
- }
-
- @Override
- public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) {
- return this.getDefaultState().with(FACING, ctx.getPlayerLookDirection().getOpposite());
- }
+ @Override
+ public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) {
+ return this.getDefaultState().with(FACING, ctx.getPlayerLookDirection().getOpposite());
+ }
- @Override
- protected void appendProperties(StateManager.@NotNull Builder builder) {
- builder.add(FACING);
- }
+ @Override
+ protected void appendProperties(StateManager.@NotNull Builder builder) {
+ builder.add(FACING);
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java
index 61ecda53..52bd3420 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java
@@ -1,8 +1,13 @@
package com.github.platymemo.alaskanativecraft.block.entity;
+import java.util.Optional;
+
import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks;
import com.github.platymemo.alaskanativecraft.recipe.AlaskaRecipes;
import com.github.platymemo.alaskanativecraft.recipe.DryingRecipe;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.inventory.Inventories;
@@ -19,155 +24,151 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Optional;
public class DryingRackBlockEntity extends BlockEntity implements Clearable {
- private final DefaultedList itemsBeingDried;
- private final int[] dryingTimes;
- private final int[] dryingTotalTimes;
-
- public DryingRackBlockEntity(BlockPos pos, BlockState state) {
- super(AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, pos, state);
- this.itemsBeingDried = DefaultedList.ofSize(4, ItemStack.EMPTY);
- this.dryingTimes = new int[4];
- this.dryingTotalTimes = new int[4];
- }
-
- public static void possiblyWetTick(@NotNull World world, BlockPos pos, BlockState state, DryingRackBlockEntity dryingRackBlockEntity) {
- if (world.isSkyVisible(pos)) {
- for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) {
- if (dryingRackBlockEntity.dryingTimes[i] > 0) {
- dryingRackBlockEntity.dryingTimes[i] = MathHelper.clamp(dryingRackBlockEntity.dryingTimes[i] - 2, 0, dryingRackBlockEntity.dryingTotalTimes[i]);
- }
- }
- } else {
- updateItemsBeingDried(world, pos, state, dryingRackBlockEntity);
- }
- }
-
- @SuppressWarnings("unused")
- public static void updateItemsBeingDried(World world, BlockPos pos, BlockState state, @NotNull DryingRackBlockEntity dryingRackBlockEntity) {
- for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) {
- ItemStack itemStack = dryingRackBlockEntity.itemsBeingDried.get(i);
- if (!itemStack.isEmpty()) {
- dryingRackBlockEntity.dryingTimes[i]++;
- if (dryingRackBlockEntity.dryingTimes[i] >= dryingRackBlockEntity.dryingTotalTimes[i]) {
-
- // Don't want it to keep counting up unnecessarily high
- dryingRackBlockEntity.dryingTimes[i] = dryingRackBlockEntity.dryingTotalTimes[i];
-
- Inventory inventory = new SimpleInventory(itemStack);
- ItemStack itemStack2 = world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, inventory, world).map((dryingRecipe) -> dryingRecipe.craft(inventory)).orElse(itemStack);
- dryingRackBlockEntity.itemsBeingDried.set(i, itemStack2);
- dryingRackBlockEntity.updateListeners();
- }
- }
- }
- }
-
- @Nullable
- @Override
- public Packet toUpdatePacket() {
- return BlockEntityUpdateS2CPacket.create(this);
- }
-
- public DefaultedList getItemsBeingDried() {
- return this.itemsBeingDried;
- }
-
- public ItemStack getDriedItem() {
- ItemStack stack;
- for (int i = 0; i < this.itemsBeingDried.size(); ++i) {
- if (this.dryingTimes[i] >= this.dryingTotalTimes[i]) {
- stack = this.itemsBeingDried.get(i);
- if (!stack.isEmpty()) {
- this.itemsBeingDried.set(i, ItemStack.EMPTY);
- this.updateListeners();
- return stack;
- }
- }
- }
- for (int i = 0; i < this.itemsBeingDried.size(); ++i) {
- stack = this.itemsBeingDried.get(i);
- if (!stack.isEmpty()) {
- this.itemsBeingDried.set(i, ItemStack.EMPTY);
- this.updateListeners();
- return stack;
- }
- }
- return ItemStack.EMPTY;
- }
-
- @Override
- public void readNbt(NbtCompound nbt) {
- this.itemsBeingDried.clear();
- Inventories.readNbt(nbt, this.itemsBeingDried);
- int[] js;
- if (nbt.contains("DryingTimes", 11)) {
- js = nbt.getIntArray("DryingTimes");
- System.arraycopy(js, 0, this.dryingTimes, 0, Math.min(this.dryingTotalTimes.length, js.length));
- }
- }
-
- @Override
- public void writeNbt(NbtCompound nbt) {
- saveInitialChunkData(nbt);
- nbt.putIntArray("DryingTimes", dryingTimes);
- nbt.putIntArray("DryingTotalTimes", dryingTotalTimes);
- }
-
- private NbtCompound saveInitialChunkData(NbtCompound tag) {
- Inventories.writeNbt(tag, this.itemsBeingDried, true);
- return tag;
- }
-
- @Override
- public NbtCompound toInitialChunkDataNbt() {
- return this.saveInitialChunkData(new NbtCompound());
- }
-
- @SuppressWarnings("ConstantConditions")
- public Optional getRecipeFor(ItemStack item) {
- return this.itemsBeingDried.stream().noneMatch(ItemStack::isEmpty) ? Optional.empty() : this.world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, new SimpleInventory(item), this.world);
- }
-
- public boolean addItem(ItemStack item, int integer) {
- for (int i = 0; i < this.itemsBeingDried.size(); ++i) {
- ItemStack itemStack = this.itemsBeingDried.get(i);
- if (itemStack.isEmpty()) {
- this.dryingTotalTimes[i] = integer;
- this.dryingTimes[i] = 0;
- this.itemsBeingDried.set(i, item.split(1));
- this.updateListeners();
- return true;
- }
- }
-
- return false;
- }
-
- @SuppressWarnings("ConstantConditions")
- private void updateListeners() {
- this.markDirty();
- this.getWorld().updateListeners(this.getPos(), this.getCachedState(), this.getCachedState(), 3);
- }
-
- @Override
- public void clear() {
- this.itemsBeingDried.clear();
- }
-
- public void spawnItemsBeingDried() {
- if (this.world != null) {
- if (!this.world.isClient) {
- ItemScatterer.spawn(this.world, this.getPos(), this.getItemsBeingDried());
- }
-
- this.updateListeners();
- }
-
- }
+ private final DefaultedList itemsBeingDried;
+ private final int[] dryingTimes;
+ private final int[] dryingTotalTimes;
+
+ public DryingRackBlockEntity(BlockPos pos, BlockState state) {
+ super(AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, pos, state);
+ this.itemsBeingDried = DefaultedList.ofSize(4, ItemStack.EMPTY);
+ this.dryingTimes = new int[4];
+ this.dryingTotalTimes = new int[4];
+ }
+
+ public static void possiblyWetTick(@NotNull World world, BlockPos pos, BlockState state, DryingRackBlockEntity dryingRackBlockEntity) {
+ if (world.isSkyVisible(pos)) {
+ for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) {
+ if (dryingRackBlockEntity.dryingTimes[i] > 0) {
+ dryingRackBlockEntity.dryingTimes[i] = MathHelper.clamp(dryingRackBlockEntity.dryingTimes[i] - 2, 0, dryingRackBlockEntity.dryingTotalTimes[i]);
+ }
+ }
+ } else {
+ updateItemsBeingDried(world, pos, state, dryingRackBlockEntity);
+ }
+ }
+
+ @SuppressWarnings("unused")
+ public static void updateItemsBeingDried(World world, BlockPos pos, BlockState state, @NotNull DryingRackBlockEntity dryingRackBlockEntity) {
+ for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) {
+ ItemStack itemStack = dryingRackBlockEntity.itemsBeingDried.get(i);
+ if (!itemStack.isEmpty()) {
+ dryingRackBlockEntity.dryingTimes[i]++;
+ if (dryingRackBlockEntity.dryingTimes[i] >= dryingRackBlockEntity.dryingTotalTimes[i]) {
+ // Don't want it to keep counting up unnecessarily high
+ dryingRackBlockEntity.dryingTimes[i] = dryingRackBlockEntity.dryingTotalTimes[i];
+
+ Inventory inventory = new SimpleInventory(itemStack);
+ ItemStack itemStack2 = world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, inventory, world).map((dryingRecipe) -> dryingRecipe.craft(inventory)).orElse(itemStack);
+ dryingRackBlockEntity.itemsBeingDried.set(i, itemStack2);
+ dryingRackBlockEntity.updateListeners();
+ }
+ }
+ }
+ }
+
+ @Nullable
+ @Override
+ public Packet toUpdatePacket() {
+ return BlockEntityUpdateS2CPacket.of(this);
+ }
+
+ public DefaultedList getItemsBeingDried() {
+ return this.itemsBeingDried;
+ }
+
+ public ItemStack getDriedItem() {
+ ItemStack stack;
+ for (int i = 0; i < this.itemsBeingDried.size(); ++i) {
+ if (this.dryingTimes[i] >= this.dryingTotalTimes[i]) {
+ stack = this.itemsBeingDried.get(i);
+ if (!stack.isEmpty()) {
+ this.itemsBeingDried.set(i, ItemStack.EMPTY);
+ this.updateListeners();
+ return stack;
+ }
+ }
+ }
+
+ for (int i = 0; i < this.itemsBeingDried.size(); ++i) {
+ stack = this.itemsBeingDried.get(i);
+ if (!stack.isEmpty()) {
+ this.itemsBeingDried.set(i, ItemStack.EMPTY);
+ this.updateListeners();
+ return stack;
+ }
+ }
+
+ return ItemStack.EMPTY;
+ }
+
+ @Override
+ public void readNbt(NbtCompound nbt) {
+ this.itemsBeingDried.clear();
+ Inventories.readNbt(nbt, this.itemsBeingDried);
+ int[] js;
+ if (nbt.contains("DryingTimes", 11)) {
+ js = nbt.getIntArray("DryingTimes");
+ System.arraycopy(js, 0, this.dryingTimes, 0, Math.min(this.dryingTotalTimes.length, js.length));
+ }
+ }
+
+ @Override
+ public void writeNbt(NbtCompound nbt) {
+ this.saveInitialChunkData(nbt);
+ nbt.putIntArray("DryingTimes", this.dryingTimes);
+ nbt.putIntArray("DryingTotalTimes", this.dryingTotalTimes);
+ }
+
+ private NbtCompound saveInitialChunkData(NbtCompound tag) {
+ Inventories.writeNbt(tag, this.itemsBeingDried, true);
+ return tag;
+ }
+
+ @Override
+ public NbtCompound toInitialChunkDataNbt() {
+ return this.saveInitialChunkData(new NbtCompound());
+ }
+
+ @SuppressWarnings("ConstantConditions")
+ public Optional getRecipeFor(ItemStack item) {
+ return this.itemsBeingDried.stream().noneMatch(ItemStack::isEmpty) ? Optional.empty() : this.world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, new SimpleInventory(item), this.world);
+ }
+
+ public boolean addItem(ItemStack item, int integer) {
+ for (int i = 0; i < this.itemsBeingDried.size(); ++i) {
+ ItemStack itemStack = this.itemsBeingDried.get(i);
+ if (itemStack.isEmpty()) {
+ this.dryingTotalTimes[i] = integer;
+ this.dryingTimes[i] = 0;
+ this.itemsBeingDried.set(i, item.split(1));
+ this.updateListeners();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @SuppressWarnings("ConstantConditions")
+ private void updateListeners() {
+ this.markDirty();
+ this.getWorld().updateListeners(this.getPos(), this.getCachedState(), this.getCachedState(), 3);
+ }
+
+ @Override
+ public void clear() {
+ this.itemsBeingDried.clear();
+ }
+
+ public void spawnItemsBeingDried() {
+ if (this.world != null) {
+ if (!this.world.isClient) {
+ ItemScatterer.spawn(this.world, this.getPos(), this.getItemsBeingDried());
+ }
+
+ this.updateListeners();
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java
index cc8d6cd6..6aadf67a 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java
@@ -6,34 +6,35 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
-import net.minecraft.client.render.entity.model.EntityModelLayer;
-import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
+import net.minecraft.client.render.entity.model.EntityModelLayer;
+import net.minecraft.util.Identifier;
+
@Environment(EnvType.CLIENT)
public class AlaskaModels {
- public static final EntityModelLayer PTARMIGAN = registerMain("ptarmigan");
- public static final EntityModelLayer DOGSLED = registerMain("dogsled");
- public static final EntityModelLayer HARPOON = registerMain("harpoon");
- public static final EntityModelLayer MOOSE = registerMain("moose");
- public static final EntityModelLayer SEAL = registerMain("seal");
- public static final EntityModelLayer KUSPUK_SKIRT = registerMain("kuspuk_skirt");
- public static final EntityModelLayer SNOWSHOES = registerMain("snowshoes");
+ public static final EntityModelLayer PTARMIGAN = registerMain("ptarmigan");
+ public static final EntityModelLayer DOGSLED = registerMain("dogsled");
+ public static final EntityModelLayer HARPOON = registerMain("harpoon");
+ public static final EntityModelLayer MOOSE = registerMain("moose");
+ public static final EntityModelLayer SEAL = registerMain("seal");
+ public static final EntityModelLayer KUSPUK_SKIRT = registerMain("kuspuk_skirt");
+ public static final EntityModelLayer SNOWSHOES = registerMain("snowshoes");
- @Contract("_ -> new")
- private static @NotNull EntityModelLayer registerMain(String id) {
- return new EntityModelLayer(new Identifier(AlaskaNativeCraft.MOD_ID, id), "main");
- }
+ @Contract("_ -> new")
+ private static @NotNull EntityModelLayer registerMain(String id) {
+ return new EntityModelLayer(new Identifier(AlaskaNativeCraft.MOD_ID, id), "main");
+ }
- @Environment(EnvType.CLIENT)
- public static void registerEntityModels() {
- EntityModelLayerRegistry.registerModelLayer(PTARMIGAN, PtarmiganEntityModel::getTexturedModelData);
- EntityModelLayerRegistry.registerModelLayer(DOGSLED, DogsledEntityModel::getTexturedModelData);
- EntityModelLayerRegistry.registerModelLayer(HARPOON, HarpoonEntityModel::getTexturedModelData);
- EntityModelLayerRegistry.registerModelLayer(MOOSE, MooseEntityModel::getTexturedModelData);
- EntityModelLayerRegistry.registerModelLayer(SEAL, SealEntityModel::getTexturedModelData);
- EntityModelLayerRegistry.registerModelLayer(KUSPUK_SKIRT, KuspukSkirtModel::getTexturedModelData);
- EntityModelLayerRegistry.registerModelLayer(SNOWSHOES, SnowshoeModel::getTexturedModelData);
- }
+ @Environment(EnvType.CLIENT)
+ public static void registerEntityModels() {
+ EntityModelLayerRegistry.registerModelLayer(PTARMIGAN, PtarmiganEntityModel::getTexturedModelData);
+ EntityModelLayerRegistry.registerModelLayer(DOGSLED, DogsledEntityModel::getTexturedModelData);
+ EntityModelLayerRegistry.registerModelLayer(HARPOON, HarpoonEntityModel::getTexturedModelData);
+ EntityModelLayerRegistry.registerModelLayer(MOOSE, MooseEntityModel::getTexturedModelData);
+ EntityModelLayerRegistry.registerModelLayer(SEAL, SealEntityModel::getTexturedModelData);
+ EntityModelLayerRegistry.registerModelLayer(KUSPUK_SKIRT, KuspukSkirtModel::getTexturedModelData);
+ EntityModelLayerRegistry.registerModelLayer(SNOWSHOES, SnowshoeModel::getTexturedModelData);
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java
index 9a50ebcb..452d4c68 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java
@@ -2,101 +2,108 @@
import com.github.platymemo.alaskanativecraft.entity.DogsledEntity;
import com.google.common.collect.ImmutableList;
-import net.minecraft.client.model.*;
-import net.minecraft.client.render.VertexConsumer;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
+import net.minecraft.client.model.ModelData;
+import net.minecraft.client.model.ModelPart;
+import net.minecraft.client.model.ModelPartBuilder;
+import net.minecraft.client.model.ModelPartData;
+import net.minecraft.client.model.ModelTransform;
+import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.CompositeEntityModel;
import net.minecraft.client.util.math.MatrixStack;
-import org.jetbrains.annotations.NotNull;
public class DogsledEntityModel extends CompositeEntityModel {
- private final ModelPart frame;
- private final ImmutableList parts;
-
- public DogsledEntityModel(@NotNull ModelPart modelPart) {
- frame = modelPart.getChild("frame");
- ModelPart leftRunner = modelPart.getChild("leftRunner");
- ModelPart rightRunner = modelPart.getChild("rightRunner");
-
- ImmutableList.Builder builder = ImmutableList.builder();
- builder.add(this.frame).add(leftRunner).add(rightRunner);
- this.parts = builder.build();
- }
-
- public static @NotNull TexturedModelData getTexturedModelData() {
- ModelData modelData = new ModelData();
- ModelPartData modelPartData = modelData.getRoot();
-
- ModelPartData frame = modelPartData.addChild("frame", ModelPartBuilder.create()
- .uv(20, 18)
- .cuboid(-5.0F, -9.0F, -18.0F, 10.0F, 1.0F, 1.0F)
- .uv(0, 0)
- .cuboid(-4.0F, -9.0F, -17.0F, 8.0F, 1.0F, 17.0F)
- .uv(0, 18)
- .cuboid(-4.0f, -14.0f, -1.0f, 8.0f, 1.0f, 1.0f),
- ModelTransform.pivot(0.0f, 24.0f, 3.0f));
-
- ModelPartData leftRunner = modelPartData.addChild("leftRunner", ModelPartBuilder.create()
- .uv(0, 18)
- .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F)
- .uv(0, 0)
- .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F)
- .uv(0, 20)
- .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F)
- .uv(20, 20)
- .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f),
- ModelTransform.pivot(5.0f, 0.0f, 0.0f));
-
- leftRunner.addChild("cube_r1", ModelPartBuilder.create()
- .uv(29, 30)
- .cuboid(-0.999f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f),
- ModelTransform.of(0.0f, -10.0f, 2.0f,
- 0.6109f, 0.0f, 0.0f));
-
- leftRunner.addChild("cube_r2", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-0.499f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f),
- ModelTransform.of(-0.5f, 0.0f, -9.0f,
- -0.6109f, 0.0f, 0.0f));
-
- ModelPartData rightRunner = modelPartData.addChild("rightRunner", ModelPartBuilder.create()
- .uv(0, 18)
- .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F)
- .uv(0, 0)
- .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F)
- .uv(0, 20)
- .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F)
- .uv(20, 20)
- .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f),
- ModelTransform.pivot(-4.0f, 0.0f, 0.0f));
-
- rightRunner.addChild("cube_r3", ModelPartBuilder.create()
- .uv(29, 30)
- .cuboid(-1.001f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f),
- ModelTransform.of(0.0f, -10.0f, 2.0f,
- 0.6109f, 0.0f, 0.0f));
-
- rightRunner.addChild("cube_r4", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-0.501f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f),
- ModelTransform.of(-0.5f, 0.0f, -9.0f,
- -0.6109f, 0.0f, 0.0f));
-
- return TexturedModelData.of(modelData, 64, 64);
- }
-
- @Override
- public void setAngles(DogsledEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
- this.frame.pivotY = 4.0F - animationProgress;
- }
-
- @Override
- public ImmutableList getParts() {
- return this.parts;
- }
-
- @Override
- public void render(@NotNull MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
- matrices.translate(0.0F, 0.0F, 0.3F);
- super.render(matrices, vertices, light, overlay, red, green, blue, alpha);
- }
-}
\ No newline at end of file
+ private final ModelPart frame;
+ private final ImmutableList parts;
+
+ public DogsledEntityModel(@NotNull ModelPart modelPart) {
+ this.frame = modelPart.getChild("frame");
+ ModelPart leftRunner = modelPart.getChild("leftRunner");
+ ModelPart rightRunner = modelPart.getChild("rightRunner");
+
+ ImmutableList.Builder builder = ImmutableList.builder();
+ builder.add(this.frame).add(leftRunner).add(rightRunner);
+ this.parts = builder.build();
+ }
+
+ public static @NotNull TexturedModelData getTexturedModelData() {
+ ModelData modelData = new ModelData();
+ ModelPartData modelPartData = modelData.getRoot();
+
+ ModelPartData frame = modelPartData.addChild("frame", ModelPartBuilder.create()
+ .uv(20, 18)
+ .cuboid(-5.0F, -9.0F, -18.0F, 10.0F, 1.0F, 1.0F)
+ .uv(0, 0)
+ .cuboid(-4.0F, -9.0F, -17.0F, 8.0F, 1.0F, 17.0F)
+ .uv(0, 18)
+ .cuboid(-4.0f, -14.0f, -1.0f, 8.0f, 1.0f, 1.0f),
+ ModelTransform.pivot(0.0f, 24.0f, 3.0f));
+
+ ModelPartData leftRunner = modelPartData.addChild("leftRunner", ModelPartBuilder.create()
+ .uv(0, 18)
+ .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F)
+ .uv(0, 0)
+ .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F)
+ .uv(0, 20)
+ .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F)
+ .uv(20, 20)
+ .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f),
+ ModelTransform.pivot(5.0f, 0.0f, 0.0f));
+
+ leftRunner.addChild("cube_r1", ModelPartBuilder.create()
+ .uv(29, 30)
+ .cuboid(-0.999f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f),
+ ModelTransform.of(0.0f, -10.0f, 2.0f,
+ 0.6109f, 0.0f, 0.0f));
+
+ leftRunner.addChild("cube_r2", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-0.499f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f),
+ ModelTransform.of(-0.5f, 0.0f, -9.0f,
+ -0.6109f, 0.0f, 0.0f));
+
+ ModelPartData rightRunner = modelPartData.addChild("rightRunner", ModelPartBuilder.create()
+ .uv(0, 18)
+ .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F)
+ .uv(0, 0)
+ .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F)
+ .uv(0, 20)
+ .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F)
+ .uv(20, 20)
+ .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f),
+ ModelTransform.pivot(-4.0f, 0.0f, 0.0f));
+
+ rightRunner.addChild("cube_r3", ModelPartBuilder.create()
+ .uv(29, 30)
+ .cuboid(-1.001f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f),
+ ModelTransform.of(0.0f, -10.0f, 2.0f,
+ 0.6109f, 0.0f, 0.0f));
+
+ rightRunner.addChild("cube_r4", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-0.501f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f),
+ ModelTransform.of(-0.5f, 0.0f, -9.0f,
+ -0.6109f, 0.0f, 0.0f));
+
+ return TexturedModelData.of(modelData, 64, 64);
+ }
+
+ @Override
+ public void setAngles(DogsledEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
+ this.frame.pivotY = 4.0F - animationProgress;
+ }
+
+ @Override
+ public ImmutableList getParts() {
+ return this.parts;
+ }
+
+ @Override
+ public void render(@NotNull MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
+ matrices.translate(0.0F, 0.0F, 0.3F);
+ super.render(matrices, vertices, light, overlay, red, green, blue, alpha);
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java
index 6a607fd4..a3f9cb60 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java
@@ -1,59 +1,64 @@
package com.github.platymemo.alaskanativecraft.client.model.entity;
import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity;
-import net.minecraft.client.model.*;
-import net.minecraft.client.render.entity.model.SinglePartEntityModel;
import org.jetbrains.annotations.NotNull;
+import net.minecraft.client.model.ModelData;
+import net.minecraft.client.model.ModelPart;
+import net.minecraft.client.model.ModelPartBuilder;
+import net.minecraft.client.model.ModelPartData;
+import net.minecraft.client.model.ModelTransform;
+import net.minecraft.client.model.TexturedModelData;
+import net.minecraft.client.render.entity.model.SinglePartEntityModel;
+
public class HarpoonEntityModel extends SinglePartEntityModel {
- private static final String BODY = "body";
- private static final String TIP = "tip";
- private static final String WRAP = "wrap";
- private static final String PRONG = "prong";
- private final ModelPart root;
-
- public HarpoonEntityModel(ModelPart root) {
- this.root = root;
- }
-
- public static @NotNull TexturedModelData getTexturedModelData() {
- ModelData modelData = new ModelData();
- ModelPartData root = modelData.getRoot();
- root.addChild(BODY,
- ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(6.0F, -19.0F, -8.0F, 1.0F, 27.0F, 1.0F),
- ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
- );
- root.addChild(WRAP,
- ModelPartBuilder.create()
- .uv(4, 4)
- .cuboid(6.0F, -20.0F, -9.0F, 1.0F, 1.0F, 2.0F),
- ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
- );
- root.addChild(PRONG,
- ModelPartBuilder.create()
- .uv(4, 0)
- .cuboid(6.0F, -19.0F, -10.0F, 1.0F, 2.0F, 1.0F),
- ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
- );
- root.addChild(TIP,
- ModelPartBuilder.create()
- .uv(4, 0)
- .cuboid(6.0F, -23.0F, -8.0F, 1.0F, 3.0F, 1.0F),
- ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
- );
-
- return TexturedModelData.of(modelData, 32, 32);
- }
-
- @Override
- public ModelPart getPart() {
- return root;
- }
-
- @Override
- public void setAngles(HarpoonEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
-
- }
-}
\ No newline at end of file
+ private static final String BODY = "body";
+ private static final String TIP = "tip";
+ private static final String WRAP = "wrap";
+ private static final String PRONG = "prong";
+ private final ModelPart root;
+
+ public HarpoonEntityModel(ModelPart root) {
+ this.root = root;
+ }
+
+ public static @NotNull TexturedModelData getTexturedModelData() {
+ ModelData modelData = new ModelData();
+ ModelPartData root = modelData.getRoot();
+ root.addChild(BODY,
+ ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(6.0F, -19.0F, -8.0F, 1.0F, 27.0F, 1.0F),
+ ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
+ );
+ root.addChild(WRAP,
+ ModelPartBuilder.create()
+ .uv(4, 4)
+ .cuboid(6.0F, -20.0F, -9.0F, 1.0F, 1.0F, 2.0F),
+ ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
+ );
+ root.addChild(PRONG,
+ ModelPartBuilder.create()
+ .uv(4, 0)
+ .cuboid(6.0F, -19.0F, -10.0F, 1.0F, 2.0F, 1.0F),
+ ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
+ );
+ root.addChild(TIP,
+ ModelPartBuilder.create()
+ .uv(4, 0)
+ .cuboid(6.0F, -23.0F, -8.0F, 1.0F, 3.0F, 1.0F),
+ ModelTransform.pivot(-6.0F, 16.0F, 7.0F)
+ );
+
+ return TexturedModelData.of(modelData, 32, 32);
+ }
+
+ @Override
+ public ModelPart getPart() {
+ return this.root;
+ }
+
+ @Override
+ public void setAngles(HarpoonEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java
index 83afdbb6..1d993bc0 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java
@@ -2,177 +2,183 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.model.*;
+import org.jetbrains.annotations.NotNull;
+
+import net.minecraft.client.model.ModelData;
+import net.minecraft.client.model.ModelPart;
+import net.minecraft.client.model.ModelPartBuilder;
+import net.minecraft.client.model.ModelPartData;
+import net.minecraft.client.model.ModelTransform;
+import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.EntityModelPartNames;
import net.minecraft.client.render.entity.model.QuadrupedEntityModel;
import net.minecraft.entity.Entity;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class MooseEntityModel extends QuadrupedEntityModel {
- public MooseEntityModel(ModelPart root) {
- super(root, true, 14.0F, 3.0F, 2.0F, 2.0F, 24);
- }
-
- public static @NotNull TexturedModelData getTexturedModelData() {
- ModelData modelData = new ModelData();
- ModelPartData modelPartData = modelData.getRoot();
- ModelPartData body = modelPartData.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create()
- .uv(0, 25)
- .cuboid(-3.5F, -5.0F, -11.0F, 7.0F, 10.0F, 9.0F)
- .uv(0, 0)
- .cuboid(-3.5F, -4.0F, -2.0F, 7.0F, 9.0F, 16.0F)
- .uv(42, 11)
- .cuboid(-1.0f, -3.0f, 14.0f, 2.0f, 3.0f, 1.0f),
- ModelTransform.pivot(0.5f, 7.0f, 0.0f));
-
- body.addChild("hump", ModelPartBuilder.create()
- .uv(30, 0)
- .cuboid(-3.0f, -6.0f, -10.0f, 6.0f, 4.0f, 7.0f),
- ModelTransform.of(0.0f, 2.0f, -1.8f,
- -0.4363f, 0.0f, 0.0f));
-
- modelPartData.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create()
- .uv(0, 1)
- .cuboid(-1.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F)
- .uv(52, 30)
- .cuboid(0.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f),
- ModelTransform.pivot(4.0f, 6.0f, 9.0f));
-
- modelPartData.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create()
- .uv(0, 1)
- .cuboid(-2.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F)
- .uv(52, 30)
- .cuboid(-2.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f),
- ModelTransform.pivot(-3.0f, 6.0f, 9.0f));
-
- modelPartData.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create()
- .uv(0, 1)
- .cuboid(-1.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F)
- .uv(52, 30)
- .cuboid(0.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f),
- ModelTransform.pivot(4.0f, 6.0f, -6.0f));
-
- modelPartData.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create()
- .uv(0, 1)
- .cuboid(-2.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F)
- .uv(52, 30)
- .cuboid(-2.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f),
- ModelTransform.pivot(-3.0f, 6.0f, -6.0f));
-
- ModelPartData head = modelPartData.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create()
- .uv(0, 0),
- ModelTransform.pivot(0.5f, 6.5f, -8.0f));
-
- head.addChild("snout", ModelPartBuilder.create()
- .uv(46, 12)
- .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 3.0f),
- ModelTransform.of(-0.5f, -1.8f, -11.8f,
- 0.6109f, 0.0f, 0.0f));
-
- head.addChild(EntityModelPartNames.NOSE, ModelPartBuilder.create()
- .uv(23, 25)
- .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 4.0f),
- ModelTransform.of(-0.5f, -1.6f, -10.0f,
- 0.1745f, 0.0f, 0.0f));
-
- head.addChild("headBase", ModelPartBuilder.create()
- .uv(41, 20)
- .cuboid(-2.0f, -2.0f, -2.0f, 5.0f, 5.0f, 5.0f),
- ModelTransform.of(-0.5f, -2.0f, -8.0f,
- 0.5236f, 0.0f, 0.0f));
-
- ModelPartData leftAntler = head.addChild("leftAntler", ModelPartBuilder.create()
- .uv(0, 0),
- ModelTransform.pivot(2.5f, -4.0f, -6.5f));
-
- leftAntler.addChild("leftAntlerProng3", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
- ModelTransform.of(4.3f, -0.8f, -0.6f,
- -0.6116f, -0.0114f, 0.1304f));
-
- leftAntler.addChild("leftAntlerProng2", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
- ModelTransform.of(3.3f, -0.6f, -0.4f,
- -0.6106f, 0.0907f, -0.0358f));
-
- leftAntler.addChild("leftAntlerProng1", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
- ModelTransform.of(2.3f, -0.6f, -0.4f,
- -0.6979f, -0.0831f, -0.0511f));
-
- leftAntler.addChild("leftAntlerSideProng", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-1.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f),
- ModelTransform.of(4.5f, -0.1f, -0.7f,
- 0.0756f, -0.0436f, 0.5219f));
-
- leftAntler.addChild("leftAntlerFrontProng", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-1.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f),
- ModelTransform.of(3.7f, -0.1f, -0.7f,
- 0.8782f, 0.3477f, 0.0317f));
-
- leftAntler.addChild("leftAntlerBase", ModelPartBuilder.create()
- .uv(30, 11)
- .cuboid(-1.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f),
- ModelTransform.of(0.5f, 0.4f, -0.7f,
- -0.1309f, 0.0f, -0.1745f));
-
- ModelPartData rightAntler = head.addChild("rightAntler", ModelPartBuilder.create()
- .uv(0, 0),
- ModelTransform.pivot(-2.5f, -4.0f, -6.5f));
-
- rightAntler.addChild("rightAntlerProng3", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
- ModelTransform.of(-4.3f, -0.8f, -0.6f,
- -0.6116f, 0.0114f, -0.1304f));
-
- rightAntler.addChild("rightAntlerProng2", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
- ModelTransform.of(-3.3f, -0.6f, -0.4f,
- -0.6106f, -0.0907f, 0.0358f));
-
- rightAntler.addChild("rightAntlerProng1", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
- ModelTransform.of(-2.3f, -0.6f, -0.4f,
- -0.6979f, 0.0831f, 0.0511f));
-
- rightAntler.addChild("rightAntlerSideProng", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(0.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f),
- ModelTransform.of(-4.5f, -0.1f, -0.7f,
- 0.0756f, 0.0436f, -0.5219f));
-
- rightAntler.addChild("rightAntlerFrontProng", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(0.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f),
- ModelTransform.of(-3.7f, -0.1f, -0.7f,
- 0.8782f, -0.3477f, -0.0317f));
-
- rightAntler.addChild("rightAntlerBase", ModelPartBuilder.create()
- .uv(30, 11)
- .cuboid(-4.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f),
- ModelTransform.of(-0.5f, 0.4f, -0.7f,
- -0.1309f, 0.0f, 0.1745f));
-
- ModelPartData neck = head.addChild(EntityModelPartNames.NECK, ModelPartBuilder.create()
- .uv(32, 32)
- .cuboid(-1.5f, -2.5f, -7.0f, 3.0f, 5.0f, 7.0f),
- ModelTransform.of(0.0f, 0.0f, 0.0f,
- -0.2182f, 0.0f, 0.0f));
-
- neck.addChild("dewlap", ModelPartBuilder.create()
- .uv(0, 21)
- .cuboid(1.0f, -3.0f, -2.0f, 0.0f, 6.0f, 4.0f),
- ModelTransform.pivot(-0.5f, 5.3817f, -4.3128f));
-
- return TexturedModelData.of(modelData, 64, 64);
- }
-}
\ No newline at end of file
+ public MooseEntityModel(ModelPart root) {
+ super(root, true, 14.0F, 3.0F, 2.0F, 2.0F, 24);
+ }
+
+ public static @NotNull TexturedModelData getTexturedModelData() {
+ ModelData modelData = new ModelData();
+ ModelPartData modelPartData = modelData.getRoot();
+ ModelPartData body = modelPartData.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create()
+ .uv(0, 25)
+ .cuboid(-3.5F, -5.0F, -11.0F, 7.0F, 10.0F, 9.0F)
+ .uv(0, 0)
+ .cuboid(-3.5F, -4.0F, -2.0F, 7.0F, 9.0F, 16.0F)
+ .uv(42, 11)
+ .cuboid(-1.0f, -3.0f, 14.0f, 2.0f, 3.0f, 1.0f),
+ ModelTransform.pivot(0.5f, 7.0f, 0.0f));
+
+ body.addChild("hump", ModelPartBuilder.create()
+ .uv(30, 0)
+ .cuboid(-3.0f, -6.0f, -10.0f, 6.0f, 4.0f, 7.0f),
+ ModelTransform.of(0.0f, 2.0f, -1.8f,
+ -0.4363f, 0.0f, 0.0f));
+
+ modelPartData.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create()
+ .uv(0, 1)
+ .cuboid(-1.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F)
+ .uv(52, 30)
+ .cuboid(0.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f),
+ ModelTransform.pivot(4.0f, 6.0f, 9.0f));
+
+ modelPartData.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create()
+ .uv(0, 1)
+ .cuboid(-2.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F)
+ .uv(52, 30)
+ .cuboid(-2.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f),
+ ModelTransform.pivot(-3.0f, 6.0f, 9.0f));
+
+ modelPartData.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create()
+ .uv(0, 1)
+ .cuboid(-1.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F)
+ .uv(52, 30)
+ .cuboid(0.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f),
+ ModelTransform.pivot(4.0f, 6.0f, -6.0f));
+
+ modelPartData.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create()
+ .uv(0, 1)
+ .cuboid(-2.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F)
+ .uv(52, 30)
+ .cuboid(-2.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f),
+ ModelTransform.pivot(-3.0f, 6.0f, -6.0f));
+
+ ModelPartData head = modelPartData.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create()
+ .uv(0, 0),
+ ModelTransform.pivot(0.5f, 6.5f, -8.0f));
+
+ head.addChild("snout", ModelPartBuilder.create()
+ .uv(46, 12)
+ .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 3.0f),
+ ModelTransform.of(-0.5f, -1.8f, -11.8f,
+ 0.6109f, 0.0f, 0.0f));
+
+ head.addChild(EntityModelPartNames.NOSE, ModelPartBuilder.create()
+ .uv(23, 25)
+ .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 4.0f),
+ ModelTransform.of(-0.5f, -1.6f, -10.0f,
+ 0.1745f, 0.0f, 0.0f));
+
+ head.addChild("headBase", ModelPartBuilder.create()
+ .uv(41, 20)
+ .cuboid(-2.0f, -2.0f, -2.0f, 5.0f, 5.0f, 5.0f),
+ ModelTransform.of(-0.5f, -2.0f, -8.0f,
+ 0.5236f, 0.0f, 0.0f));
+
+ ModelPartData leftAntler = head.addChild("leftAntler", ModelPartBuilder.create()
+ .uv(0, 0),
+ ModelTransform.pivot(2.5f, -4.0f, -6.5f));
+
+ leftAntler.addChild("leftAntlerProng3", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
+ ModelTransform.of(4.3f, -0.8f, -0.6f,
+ -0.6116f, -0.0114f, 0.1304f));
+
+ leftAntler.addChild("leftAntlerProng2", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
+ ModelTransform.of(3.3f, -0.6f, -0.4f,
+ -0.6106f, 0.0907f, -0.0358f));
+
+ leftAntler.addChild("leftAntlerProng1", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
+ ModelTransform.of(2.3f, -0.6f, -0.4f,
+ -0.6979f, -0.0831f, -0.0511f));
+
+ leftAntler.addChild("leftAntlerSideProng", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-1.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f),
+ ModelTransform.of(4.5f, -0.1f, -0.7f,
+ 0.0756f, -0.0436f, 0.5219f));
+
+ leftAntler.addChild("leftAntlerFrontProng", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-1.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f),
+ ModelTransform.of(3.7f, -0.1f, -0.7f,
+ 0.8782f, 0.3477f, 0.0317f));
+
+ leftAntler.addChild("leftAntlerBase", ModelPartBuilder.create()
+ .uv(30, 11)
+ .cuboid(-1.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f),
+ ModelTransform.of(0.5f, 0.4f, -0.7f,
+ -0.1309f, 0.0f, -0.1745f));
+
+ ModelPartData rightAntler = head.addChild("rightAntler", ModelPartBuilder.create()
+ .uv(0, 0),
+ ModelTransform.pivot(-2.5f, -4.0f, -6.5f));
+
+ rightAntler.addChild("rightAntlerProng3", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
+ ModelTransform.of(-4.3f, -0.8f, -0.6f,
+ -0.6116f, 0.0114f, -0.1304f));
+
+ rightAntler.addChild("rightAntlerProng2", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
+ ModelTransform.of(-3.3f, -0.6f, -0.4f,
+ -0.6106f, -0.0907f, 0.0358f));
+
+ rightAntler.addChild("rightAntlerProng1", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f),
+ ModelTransform.of(-2.3f, -0.6f, -0.4f,
+ -0.6979f, 0.0831f, 0.0511f));
+
+ rightAntler.addChild("rightAntlerSideProng", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(0.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f),
+ ModelTransform.of(-4.5f, -0.1f, -0.7f,
+ 0.0756f, 0.0436f, -0.5219f));
+
+ rightAntler.addChild("rightAntlerFrontProng", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(0.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f),
+ ModelTransform.of(-3.7f, -0.1f, -0.7f,
+ 0.8782f, -0.3477f, -0.0317f));
+
+ rightAntler.addChild("rightAntlerBase", ModelPartBuilder.create()
+ .uv(30, 11)
+ .cuboid(-4.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f),
+ ModelTransform.of(-0.5f, 0.4f, -0.7f,
+ -0.1309f, 0.0f, 0.1745f));
+
+ ModelPartData neck = head.addChild(EntityModelPartNames.NECK, ModelPartBuilder.create()
+ .uv(32, 32)
+ .cuboid(-1.5f, -2.5f, -7.0f, 3.0f, 5.0f, 7.0f),
+ ModelTransform.of(0.0f, 0.0f, 0.0f,
+ -0.2182f, 0.0f, 0.0f));
+
+ neck.addChild("dewlap", ModelPartBuilder.create()
+ .uv(0, 21)
+ .cuboid(1.0f, -3.0f, -2.0f, 0.0f, 6.0f, 4.0f),
+ ModelTransform.pivot(-0.5f, 5.3817f, -4.3128f));
+
+ return TexturedModelData.of(modelData, 64, 64);
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java
index 59a382a5..95cfbdec 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java
@@ -3,213 +3,218 @@
import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.model.*;
-import net.minecraft.client.render.VertexConsumer;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
+import net.minecraft.client.model.ModelData;
+import net.minecraft.client.model.ModelPart;
+import net.minecraft.client.model.ModelPartBuilder;
+import net.minecraft.client.model.ModelPartData;
+import net.minecraft.client.model.ModelTransform;
+import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.EntityModelPartNames;
import net.minecraft.client.render.entity.model.SinglePartEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class PtarmiganEntityModel extends SinglePartEntityModel {
- private final ModelPart root;
- private final ModelPart body;
- private final ModelPart tail;
- private final ModelPart leftWing;
- private final ModelPart rightWing;
- private final ModelPart head;
- private final ModelPart leftLeg;
- private final ModelPart rightLeg;
-
- public PtarmiganEntityModel(@NotNull ModelPart root) {
- this.root = root;
- this.body = root.getChild(EntityModelPartNames.BODY);
- this.tail = root.getChild(EntityModelPartNames.TAIL);
- this.leftWing = root.getChild(EntityModelPartNames.LEFT_WING);
- this.rightWing = root.getChild(EntityModelPartNames.RIGHT_WING);
- this.head = root.getChild(EntityModelPartNames.HEAD);
- this.leftLeg = root.getChild(EntityModelPartNames.LEFT_LEG);
- this.rightLeg = root.getChild(EntityModelPartNames.RIGHT_LEG);
- }
-
- public static @NotNull TexturedModelData getTexturedModelData() {
- ModelData modelData = new ModelData();
- ModelPartData root = modelData.getRoot();
- root.addChild(EntityModelPartNames.BODY,
- ModelPartBuilder.create()
- .uv(0, 7)
- .cuboid(-2.5F, 0.0F, -2.5F, 5.0F, 6.0F, 5.0F),
- ModelTransform.pivot(0.0F, 16.5F, -3.0F)
- );
- root.addChild(EntityModelPartNames.TAIL,
- ModelPartBuilder.create()
- .uv(24, 0)
- .cuboid(-1.5F, -1.0F, 0.0F, 3.0F, 4.0F, 1.0F),
- ModelTransform.pivot(0.0F, 21.07F, 1.16F)
- );
- root.addChild(EntityModelPartNames.LEFT_WING,
- ModelPartBuilder.create()
- .uv(2, 22)
- .cuboid(-2.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F),
- ModelTransform.pivot(2.5F, 16.94F, -2.76F)
- );
- root.addChild(EntityModelPartNames.RIGHT_WING,
- ModelPartBuilder.create()
- .uv(2, 22)
- .cuboid(1.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F),
- ModelTransform.pivot(-2.5F, 16.94F, -2.76F)
- );
- ModelPartData head = root.addChild(EntityModelPartNames.HEAD,
- ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-1.0F, -1.5F, -1.0F, 2.0F, 3.0F, 2.0F),
- ModelTransform.pivot(0.0F, 15.69F, -2.76F)
- );
- head.addChild("beak",
- ModelPartBuilder.create()
- .uv(9, 0)
- .cuboid(-0.5F, -1.0F, -0.5F, 1.0F, 2.0F, 1.0F),
- ModelTransform.pivot(0.0F, -0.5F, -1.5F)
- );
-
- ModelPartBuilder legBuilder = ModelPartBuilder.create().uv(14, 24).cuboid(-0.5F, 0.0F, -0.5F, 1.0F, 2.0F, 1.0F);
- root.addChild(EntityModelPartNames.LEFT_LEG, legBuilder, ModelTransform.pivot(1.0F, 22.0F, -1.05F));
- root.addChild(EntityModelPartNames.RIGHT_LEG, legBuilder, ModelTransform.pivot(-1.0F, 22.0F, -1.05F));
-
- return TexturedModelData.of(modelData, 32, 32);
- }
-
- private static PtarmiganEntityModel.Pose getPose(@NotNull PtarmiganEntity ptarmigan) {
- if (ptarmigan.isSongPlaying()) {
- return PtarmiganEntityModel.Pose.PARTY;
- } else if (ptarmigan.isInSittingPose()) {
- return PtarmiganEntityModel.Pose.SITTING;
- } else {
- return ptarmigan.isInAir() ? PtarmiganEntityModel.Pose.FLYING : PtarmiganEntityModel.Pose.STANDING;
- }
- }
-
- @Override
- public ModelPart getPart() {
- return this.root;
- }
-
- @Override
- public void setAngles(PtarmiganEntity ptarmiganEntity, float f, float g, float h, float i, float j) {
- this.setAngles(getPose(ptarmiganEntity), ptarmiganEntity.age, f, g, h, i, j);
- }
-
- @Override
- public void animateModel(PtarmiganEntity ptarmiganEntity, float f, float g, float h) {
- this.animateModel(getPose(ptarmiganEntity));
- }
-
- public void poseOnShoulder(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float limbAngle, float limbDistance, float headYaw, float headPitch, int danceAngle) {
- this.animateModel(PtarmiganEntityModel.Pose.ON_SHOULDER);
- this.setAngles(PtarmiganEntityModel.Pose.ON_SHOULDER, danceAngle, limbAngle, limbDistance, 0.0F, headYaw, headPitch);
- this.root.render(matrices, vertexConsumer, light, overlay);
- }
-
- private void setAngles(@NotNull PtarmiganEntityModel.Pose pose, int danceAngle, float limbAngle, float limbDistance, float age, float headYaw, float headPitch) {
- this.head.pitch = headPitch * 0.017453292F;
- this.head.yaw = headYaw * 0.017453292F;
- this.head.roll = 0.0F;
- this.head.pivotX = 0.0F;
- this.body.pivotX = 0.0F;
- this.tail.pivotX = 0.0F;
- this.rightWing.pivotX = -1.5F;
- this.leftWing.pivotX = 1.5F;
- switch (pose) {
- case SITTING:
- break;
- case PARTY:
- float cosDanceAngle = MathHelper.cos((float) danceAngle);
- float sinDanceAngle = MathHelper.sin((float) danceAngle);
- this.head.pivotX = cosDanceAngle;
- this.head.pivotY = 15.69F + sinDanceAngle;
- this.head.pitch = 0.0F;
- this.head.yaw = 0.0F;
- this.head.roll = MathHelper.sin((float) danceAngle) * 0.4F;
- this.body.pivotX = cosDanceAngle;
- this.body.pivotY = 16.5F + sinDanceAngle;
- this.leftWing.roll = -0.0873F - age;
- this.leftWing.pivotX = 1.5F + cosDanceAngle;
- this.leftWing.pivotY = 16.94F + sinDanceAngle;
- this.rightWing.roll = 0.0873F + age;
- this.rightWing.pivotX = -1.5F + cosDanceAngle;
- this.rightWing.pivotY = 16.94F + sinDanceAngle;
- this.tail.pivotX = cosDanceAngle;
- this.tail.pivotY = 21.07F + sinDanceAngle;
- break;
- case STANDING:
- this.leftLeg.pitch += MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance;
- this.rightLeg.pitch += MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 1.4F * limbDistance;
- case FLYING:
- case ON_SHOULDER:
- default:
- float thirdOfAge = age * 0.3F;
- this.head.pivotY = 15.69F + thirdOfAge;
- this.tail.pitch = 1.015F + MathHelper.cos(limbAngle * 0.6662F) * 0.3F * limbDistance;
- this.tail.pivotY = 21.07F + thirdOfAge;
- this.body.pivotY = 16.5F + thirdOfAge;
- this.leftWing.roll = -0.0873F - age;
- this.leftWing.pivotY = 16.94F + thirdOfAge;
- this.rightWing.roll = 0.0873F + age;
- this.rightWing.pivotY = 16.94F + thirdOfAge;
- this.leftLeg.pivotY = 22.0F + thirdOfAge;
- this.rightLeg.pivotY = 22.0F + thirdOfAge;
- }
-
- }
-
- private void animateModel(@NotNull PtarmiganEntityModel.Pose pose) {
- this.body.pitch = 0.4937F;
- this.leftWing.pitch = -0.6981F;
- this.leftWing.yaw = -3.1415927F;
- this.rightWing.pitch = -0.6981F;
- this.rightWing.yaw = -3.1415927F;
- this.leftLeg.pitch = -0.0299F;
- this.rightLeg.pitch = -0.0299F;
- this.leftLeg.pivotY = 22.0F;
- this.rightLeg.pivotY = 22.0F;
- this.leftLeg.roll = 0.0F;
- this.rightLeg.roll = 0.0F;
- switch (pose) {
- case SITTING:
- this.head.pivotY = 17.59F;
- this.tail.pitch = 1.5388988F;
- this.tail.pivotY = 22.97F;
- this.body.pivotY = 18.4F;
- this.leftWing.roll = -0.0873F;
- this.leftWing.pivotY = 18.84F;
- this.rightWing.roll = 0.0873F;
- this.rightWing.pivotY = 18.84F;
- ++this.leftLeg.pivotY;
- ++this.rightLeg.pivotY;
- ++this.leftLeg.pitch;
- ++this.rightLeg.pitch;
- break;
- case PARTY:
- this.leftLeg.roll = -0.34906584F;
- this.rightLeg.roll = 0.34906584F;
- case STANDING:
- case ON_SHOULDER:
- default:
- break;
- case FLYING:
- this.leftLeg.pitch += 0.6981317F;
- this.rightLeg.pitch += 0.6981317F;
- }
-
- }
-
- @Environment(EnvType.CLIENT)
- public enum Pose {
- FLYING,
- STANDING,
- SITTING,
- PARTY,
- ON_SHOULDER
- }
+ private final ModelPart root;
+ private final ModelPart body;
+ private final ModelPart tail;
+ private final ModelPart leftWing;
+ private final ModelPart rightWing;
+ private final ModelPart head;
+ private final ModelPart leftLeg;
+ private final ModelPart rightLeg;
+
+ public PtarmiganEntityModel(@NotNull ModelPart root) {
+ this.root = root;
+ this.body = root.getChild(EntityModelPartNames.BODY);
+ this.tail = root.getChild(EntityModelPartNames.TAIL);
+ this.leftWing = root.getChild(EntityModelPartNames.LEFT_WING);
+ this.rightWing = root.getChild(EntityModelPartNames.RIGHT_WING);
+ this.head = root.getChild(EntityModelPartNames.HEAD);
+ this.leftLeg = root.getChild(EntityModelPartNames.LEFT_LEG);
+ this.rightLeg = root.getChild(EntityModelPartNames.RIGHT_LEG);
+ }
+
+ public static @NotNull TexturedModelData getTexturedModelData() {
+ ModelData modelData = new ModelData();
+ ModelPartData root = modelData.getRoot();
+ root.addChild(EntityModelPartNames.BODY,
+ ModelPartBuilder.create()
+ .uv(0, 7)
+ .cuboid(-2.5F, 0.0F, -2.5F, 5.0F, 6.0F, 5.0F),
+ ModelTransform.pivot(0.0F, 16.5F, -3.0F)
+ );
+ root.addChild(EntityModelPartNames.TAIL,
+ ModelPartBuilder.create()
+ .uv(24, 0)
+ .cuboid(-1.5F, -1.0F, 0.0F, 3.0F, 4.0F, 1.0F),
+ ModelTransform.pivot(0.0F, 21.07F, 1.16F)
+ );
+ root.addChild(EntityModelPartNames.LEFT_WING,
+ ModelPartBuilder.create()
+ .uv(2, 22)
+ .cuboid(-2.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F),
+ ModelTransform.pivot(2.5F, 16.94F, -2.76F)
+ );
+ root.addChild(EntityModelPartNames.RIGHT_WING,
+ ModelPartBuilder.create()
+ .uv(2, 22)
+ .cuboid(1.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F),
+ ModelTransform.pivot(-2.5F, 16.94F, -2.76F)
+ );
+ ModelPartData head = root.addChild(EntityModelPartNames.HEAD,
+ ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-1.0F, -1.5F, -1.0F, 2.0F, 3.0F, 2.0F),
+ ModelTransform.pivot(0.0F, 15.69F, -2.76F)
+ );
+ head.addChild("beak",
+ ModelPartBuilder.create()
+ .uv(9, 0)
+ .cuboid(-0.5F, -1.0F, -0.5F, 1.0F, 2.0F, 1.0F),
+ ModelTransform.pivot(0.0F, -0.5F, -1.5F)
+ );
+
+ ModelPartBuilder legBuilder = ModelPartBuilder.create().uv(14, 24).cuboid(-0.5F, 0.0F, -0.5F, 1.0F, 2.0F, 1.0F);
+ root.addChild(EntityModelPartNames.LEFT_LEG, legBuilder, ModelTransform.pivot(1.0F, 22.0F, -1.05F));
+ root.addChild(EntityModelPartNames.RIGHT_LEG, legBuilder, ModelTransform.pivot(-1.0F, 22.0F, -1.05F));
+
+ return TexturedModelData.of(modelData, 32, 32);
+ }
+
+ private static PtarmiganEntityModel.Pose getPose(@NotNull PtarmiganEntity ptarmigan) {
+ if (ptarmigan.isSongPlaying()) {
+ return PtarmiganEntityModel.Pose.PARTY;
+ } else if (ptarmigan.isInSittingPose()) {
+ return PtarmiganEntityModel.Pose.SITTING;
+ } else {
+ return ptarmigan.isInAir() ? PtarmiganEntityModel.Pose.FLYING : PtarmiganEntityModel.Pose.STANDING;
+ }
+ }
+
+ @Override
+ public ModelPart getPart() {
+ return this.root;
+ }
+
+ @Override
+ public void setAngles(PtarmiganEntity ptarmiganEntity, float f, float g, float h, float i, float j) {
+ this.setAngles(getPose(ptarmiganEntity), ptarmiganEntity.age, f, g, h, i, j);
+ }
+
+ @Override
+ public void animateModel(PtarmiganEntity ptarmiganEntity, float f, float g, float h) {
+ this.animateModel(getPose(ptarmiganEntity));
+ }
+
+ public void poseOnShoulder(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float limbAngle, float limbDistance, float headYaw, float headPitch, int danceAngle) {
+ this.animateModel(PtarmiganEntityModel.Pose.ON_SHOULDER);
+ this.setAngles(PtarmiganEntityModel.Pose.ON_SHOULDER, danceAngle, limbAngle, limbDistance, 0.0F, headYaw, headPitch);
+ this.root.render(matrices, vertexConsumer, light, overlay);
+ }
+
+ private void setAngles(@NotNull PtarmiganEntityModel.Pose pose, int danceAngle, float limbAngle, float limbDistance, float age, float headYaw, float headPitch) {
+ this.head.pitch = headPitch * 0.017453292F;
+ this.head.yaw = headYaw * 0.017453292F;
+ this.head.roll = 0.0F;
+ this.head.pivotX = 0.0F;
+ this.body.pivotX = 0.0F;
+ this.tail.pivotX = 0.0F;
+ this.rightWing.pivotX = -1.5F;
+ this.leftWing.pivotX = 1.5F;
+ switch (pose) {
+ case SITTING:
+ break;
+ case PARTY:
+ float cosDanceAngle = MathHelper.cos((float) danceAngle);
+ float sinDanceAngle = MathHelper.sin((float) danceAngle);
+ this.head.pivotX = cosDanceAngle;
+ this.head.pivotY = 15.69F + sinDanceAngle;
+ this.head.pitch = 0.0F;
+ this.head.yaw = 0.0F;
+ this.head.roll = MathHelper.sin((float) danceAngle) * 0.4F;
+ this.body.pivotX = cosDanceAngle;
+ this.body.pivotY = 16.5F + sinDanceAngle;
+ this.leftWing.roll = -0.0873F - age;
+ this.leftWing.pivotX = 1.5F + cosDanceAngle;
+ this.leftWing.pivotY = 16.94F + sinDanceAngle;
+ this.rightWing.roll = 0.0873F + age;
+ this.rightWing.pivotX = -1.5F + cosDanceAngle;
+ this.rightWing.pivotY = 16.94F + sinDanceAngle;
+ this.tail.pivotX = cosDanceAngle;
+ this.tail.pivotY = 21.07F + sinDanceAngle;
+ break;
+ case STANDING:
+ this.leftLeg.pitch += MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance;
+ this.rightLeg.pitch += MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 1.4F * limbDistance;
+ case FLYING:
+ case ON_SHOULDER:
+ default:
+ float thirdOfAge = age * 0.3F;
+ this.head.pivotY = 15.69F + thirdOfAge;
+ this.tail.pitch = 1.015F + MathHelper.cos(limbAngle * 0.6662F) * 0.3F * limbDistance;
+ this.tail.pivotY = 21.07F + thirdOfAge;
+ this.body.pivotY = 16.5F + thirdOfAge;
+ this.leftWing.roll = -0.0873F - age;
+ this.leftWing.pivotY = 16.94F + thirdOfAge;
+ this.rightWing.roll = 0.0873F + age;
+ this.rightWing.pivotY = 16.94F + thirdOfAge;
+ this.leftLeg.pivotY = 22.0F + thirdOfAge;
+ this.rightLeg.pivotY = 22.0F + thirdOfAge;
+ }
+ }
+
+ private void animateModel(@NotNull PtarmiganEntityModel.Pose pose) {
+ this.body.pitch = 0.4937F;
+ this.leftWing.pitch = -0.6981F;
+ this.leftWing.yaw = -3.1415927F;
+ this.rightWing.pitch = -0.6981F;
+ this.rightWing.yaw = -3.1415927F;
+ this.leftLeg.pitch = -0.0299F;
+ this.rightLeg.pitch = -0.0299F;
+ this.leftLeg.pivotY = 22.0F;
+ this.rightLeg.pivotY = 22.0F;
+ this.leftLeg.roll = 0.0F;
+ this.rightLeg.roll = 0.0F;
+ switch (pose) {
+ case SITTING:
+ this.head.pivotY = 17.59F;
+ this.tail.pitch = 1.5388988F;
+ this.tail.pivotY = 22.97F;
+ this.body.pivotY = 18.4F;
+ this.leftWing.roll = -0.0873F;
+ this.leftWing.pivotY = 18.84F;
+ this.rightWing.roll = 0.0873F;
+ this.rightWing.pivotY = 18.84F;
+ ++this.leftLeg.pivotY;
+ ++this.rightLeg.pivotY;
+ ++this.leftLeg.pitch;
+ ++this.rightLeg.pitch;
+ break;
+ case PARTY:
+ this.leftLeg.roll = -0.34906584F;
+ this.rightLeg.roll = 0.34906584F;
+ case STANDING:
+ case ON_SHOULDER:
+ default:
+ break;
+ case FLYING:
+ this.leftLeg.pitch += 0.6981317F;
+ this.rightLeg.pitch += 0.6981317F;
+ }
+ }
+
+ @Environment(EnvType.CLIENT)
+ public enum Pose {
+ FLYING,
+ STANDING,
+ SITTING,
+ PARTY,
+ ON_SHOULDER
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java
index 0db739fb..b9fc1e36 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java
@@ -5,88 +5,94 @@
import com.google.common.collect.Iterables;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.model.*;
+import org.jetbrains.annotations.NotNull;
+
+import net.minecraft.client.model.ModelData;
+import net.minecraft.client.model.ModelPart;
+import net.minecraft.client.model.ModelPartBuilder;
+import net.minecraft.client.model.ModelPartData;
+import net.minecraft.client.model.ModelTransform;
+import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.EntityModelPartNames;
import net.minecraft.client.render.entity.model.QuadrupedEntityModel;
import net.minecraft.util.math.MathHelper;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class SealEntityModel extends QuadrupedEntityModel {
- public static final String STOMACH = "stomach";
- public static final String TAIL = "tail";
- protected final ModelPart stomach;
- protected final ModelPart tail;
+ public static final String STOMACH = "stomach";
+ public static final String TAIL = "tail";
+ protected final ModelPart stomach;
+ protected final ModelPart tail;
- public SealEntityModel(ModelPart root) {
- super(root, true, 9.0F, 1.0F, 2.0F, 1.5F, 12);
- stomach = root.getChild(STOMACH);
- tail = root.getChild(TAIL);
- }
+ public SealEntityModel(ModelPart root) {
+ super(root, true, 9.0F, 1.0F, 2.0F, 1.5F, 12);
+ this.stomach = root.getChild(STOMACH);
+ this.tail = root.getChild(TAIL);
+ }
- public static @NotNull TexturedModelData getTexturedModelData() {
- ModelData modelData = new ModelData();
- ModelPartData root = modelData.getRoot();
- root.addChild(EntityModelPartNames.RIGHT_FRONT_LEG,
- ModelPartBuilder.create().uv(38, 6).cuboid(-5.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F),
- ModelTransform.of(-6.0F, 24.0F, -6.0F, 0.0F, -1.0F, 0.0F)
- );
- root.addChild(EntityModelPartNames.LEFT_FRONT_LEG,
- ModelPartBuilder.create().uv(32, 27).cuboid(0.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F),
- ModelTransform.of(5.0F, 24.0F, -6.0F, 0.0F, 1.0F, 0.0F)
- );
- root.addChild(EntityModelPartNames.RIGHT_HIND_LEG,
- ModelPartBuilder.create().uv(30, 0).cuboid(-2.0F, 0.0F, -1.0F, 3.0F, 1.0F, 5.0F),
- ModelTransform.pivot(-3.0F, 23.0F, 11.0F)
- );
- root.addChild(EntityModelPartNames.LEFT_HIND_LEG,
- ModelPartBuilder.create().uv(13, 38).cuboid(-1.0F, 0.0F, -1.1F, 3.0F, 1.0F, 5.0F),
- ModelTransform.pivot(2.0F, 23.0F, 11.1F)
- );
+ public static @NotNull TexturedModelData getTexturedModelData() {
+ ModelData modelData = new ModelData();
+ ModelPartData root = modelData.getRoot();
+ root.addChild(EntityModelPartNames.RIGHT_FRONT_LEG,
+ ModelPartBuilder.create().uv(38, 6).cuboid(-5.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F),
+ ModelTransform.of(-6.0F, 24.0F, -6.0F, 0.0F, -1.0F, 0.0F)
+ );
+ root.addChild(EntityModelPartNames.LEFT_FRONT_LEG,
+ ModelPartBuilder.create().uv(32, 27).cuboid(0.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F),
+ ModelTransform.of(5.0F, 24.0F, -6.0F, 0.0F, 1.0F, 0.0F)
+ );
+ root.addChild(EntityModelPartNames.RIGHT_HIND_LEG,
+ ModelPartBuilder.create().uv(30, 0).cuboid(-2.0F, 0.0F, -1.0F, 3.0F, 1.0F, 5.0F),
+ ModelTransform.pivot(-3.0F, 23.0F, 11.0F)
+ );
+ root.addChild(EntityModelPartNames.LEFT_HIND_LEG,
+ ModelPartBuilder.create().uv(13, 38).cuboid(-1.0F, 0.0F, -1.1F, 3.0F, 1.0F, 5.0F),
+ ModelTransform.pivot(2.0F, 23.0F, 11.1F)
+ );
- root.addChild(EntityModelPartNames.HEAD,
- ModelPartBuilder.create()
- .uv(29, 31).cuboid(EntityModelPartNames.NECK, -4.5F, -5.0F, -3.0F, 9.0F, 9.0F, 3.0F)
- .uv(32, 18).cuboid(-3.5F, -4.0F, -5.0F, 7.0F, 7.0F, 2.0F)
- .uv(38, 10).cuboid(EntityModelPartNames.NOSE, -2.5F, -1.0F, -7.0F, 5.0F, 3.0F, 2.0F),
- ModelTransform.pivot(-0.5F, 19.0F, -8.0F)
- );
- root.addChild(EntityModelPartNames.BODY,
- ModelPartBuilder.create().uv(0, 0).cuboid(-5.5F, -5.0F, -4.0F, 11.0F, 10.0F, 8.0F),
- ModelTransform.pivot(-0.5F, 19.0F, -4.0F)
- );
- root.addChild(STOMACH,
- ModelPartBuilder.create().uv(0, 18).cuboid(-4.5F, -4.5F, -3.5F, 9.0F, 9.0F, 7.0F),
- ModelTransform.pivot(-0.5F, 19.5F, 3.5F)
- );
- root.addChild(TAIL,
- ModelPartBuilder.create().uv(0, 34).cuboid(-2.5F, -2.5F, -2.0F, 5.0F, 5.0F, 4.0F),
- ModelTransform.pivot(-0.5F, 21.0F, 9.0F)
- );
- return TexturedModelData.of(modelData, 64, 64);
- }
+ root.addChild(EntityModelPartNames.HEAD,
+ ModelPartBuilder.create()
+ .uv(29, 31).cuboid(EntityModelPartNames.NECK, -4.5F, -5.0F, -3.0F, 9.0F, 9.0F, 3.0F)
+ .uv(32, 18).cuboid(-3.5F, -4.0F, -5.0F, 7.0F, 7.0F, 2.0F)
+ .uv(38, 10).cuboid(EntityModelPartNames.NOSE, -2.5F, -1.0F, -7.0F, 5.0F, 3.0F, 2.0F),
+ ModelTransform.pivot(-0.5F, 19.0F, -8.0F)
+ );
+ root.addChild(EntityModelPartNames.BODY,
+ ModelPartBuilder.create().uv(0, 0).cuboid(-5.5F, -5.0F, -4.0F, 11.0F, 10.0F, 8.0F),
+ ModelTransform.pivot(-0.5F, 19.0F, -4.0F)
+ );
+ root.addChild(STOMACH,
+ ModelPartBuilder.create().uv(0, 18).cuboid(-4.5F, -4.5F, -3.5F, 9.0F, 9.0F, 7.0F),
+ ModelTransform.pivot(-0.5F, 19.5F, 3.5F)
+ );
+ root.addChild(TAIL,
+ ModelPartBuilder.create().uv(0, 34).cuboid(-2.5F, -2.5F, -2.0F, 5.0F, 5.0F, 4.0F),
+ ModelTransform.pivot(-0.5F, 21.0F, 9.0F)
+ );
+ return TexturedModelData.of(modelData, 64, 64);
+ }
- @Override
- protected Iterable getBodyParts() {
- return Iterables.concat(super.getBodyParts(), ImmutableList.of(this.stomach), ImmutableList.of(this.tail));
- }
+ @Override
+ protected Iterable getBodyParts() {
+ return Iterables.concat(super.getBodyParts(), ImmutableList.of(this.stomach), ImmutableList.of(this.tail));
+ }
- @Override
- public void setAngles(@NotNull T sealEntity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
- this.head.pitch = headPitch * 0.017453292F;
- this.head.yaw = headYaw * 0.017453292F;
- this.body.pitch = 0.0F;
- float flipperAnim = MathHelper.cos(limbAngle * 0.4F) * 0.5F * limbDistance;
- if (!sealEntity.isTouchingWater() && sealEntity.isOnGround()) {
- this.rightHindLeg.setAngles(0.0F, -flipperAnim, 0.0F);
- this.leftHindLeg.setAngles(0.0F, flipperAnim, 0.0F);
- this.rightFrontLeg.setAngles(0.0F, -flipperAnim * 2.0F, 0.0F);
- this.leftFrontLeg.setAngles(0.0F, flipperAnim * 2.0F, 0.0F);
- } else {
- this.rightHindLeg.setAngles(flipperAnim, 0.0F, 0.0F);
- this.leftHindLeg.setAngles(-flipperAnim, 0.0F, 0.0F);
- this.rightFrontLeg.setAngles(1.0F + flipperAnim, -(flipperAnim * 2.0F), -(1.0F + flipperAnim));
- this.leftFrontLeg.setAngles(1.0F + flipperAnim, flipperAnim * 2.0F, 1.0F + flipperAnim);
- }
- }
+ @Override
+ public void setAngles(@NotNull T sealEntity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
+ this.head.pitch = headPitch * 0.017453292F;
+ this.head.yaw = headYaw * 0.017453292F;
+ this.body.pitch = 0.0F;
+ float flipperAnim = MathHelper.cos(limbAngle * 0.4F) * 0.5F * limbDistance;
+ if (!sealEntity.isTouchingWater() && sealEntity.isOnGround()) {
+ this.rightHindLeg.setAngles(0.0F, -flipperAnim, 0.0F);
+ this.leftHindLeg.setAngles(0.0F, flipperAnim, 0.0F);
+ this.rightFrontLeg.setAngles(0.0F, -flipperAnim * 2.0F, 0.0F);
+ this.leftFrontLeg.setAngles(0.0F, flipperAnim * 2.0F, 0.0F);
+ } else {
+ this.rightHindLeg.setAngles(flipperAnim, 0.0F, 0.0F);
+ this.leftHindLeg.setAngles(-flipperAnim, 0.0F, 0.0F);
+ this.rightFrontLeg.setAngles(1.0F + flipperAnim, -(flipperAnim * 2.0F), -(1.0F + flipperAnim));
+ this.leftFrontLeg.setAngles(1.0F + flipperAnim, flipperAnim * 2.0F, 1.0F + flipperAnim);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java
index f64deb58..082c53f4 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java
@@ -1,88 +1,92 @@
package com.github.platymemo.alaskanativecraft.client.model.entity.feature;
import com.google.common.collect.ImmutableList;
-import net.minecraft.client.model.*;
+import org.jetbrains.annotations.NotNull;
+
+import net.minecraft.client.model.ModelData;
+import net.minecraft.client.model.ModelPart;
+import net.minecraft.client.model.ModelPartBuilder;
+import net.minecraft.client.model.ModelPartData;
+import net.minecraft.client.model.ModelTransform;
+import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.AnimalModel;
import net.minecraft.entity.LivingEntity;
-import org.jetbrains.annotations.NotNull;
public class KuspukSkirtModel extends AnimalModel {
- private final ModelPart skirt;
-
- public KuspukSkirtModel(@NotNull ModelPart modelPart) {
- skirt = modelPart.getChild("skirt");
- }
-
- public static @NotNull TexturedModelData getTexturedModelData() {
- ModelData modelData = new ModelData();
- ModelPartData modelPartData = modelData.getRoot();
- ModelPartData skirt = modelPartData.addChild("skirt", ModelPartBuilder.create(),
- ModelTransform.pivot(0.0f, 18.0f, 2.0f));
-
- skirt.addChild("strip_1", ModelPartBuilder.create()
- .uv(0, 9)
- .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f),
- ModelTransform.of(3.7f, 0.0f, -0.3f,
- -1.309f, 0.7854f, 0.0f));
-
- skirt.addChild("strip_2", ModelPartBuilder.create()
- .uv(0, 9)
- .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f),
- ModelTransform.of(-3.7f, 0.0f, -3.7f,
- 1.309f, 0.7854f, 0.0f));
-
- skirt.addChild("strip_3", ModelPartBuilder.create()
- .uv(0, 9)
- .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f),
- ModelTransform.of(-3.7f, 0.0f, -0.3f,
- -1.309f, -0.7854f, 0.0f));
-
- skirt.addChild("strip_4", ModelPartBuilder.create()
- .uv(0, 9)
- .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f),
- ModelTransform.of(3.7f, 0.0f, -3.7f,
- 1.309f, -0.7854f, 0.0f));
-
- skirt.addChild("right", ModelPartBuilder.create()
- .uv(0, 5)
- .cuboid(-5.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f),
- ModelTransform.of(-4.0f, 0.0f, -2.0f,
- 0.0f, 0.0f, -1.309f));
-
- skirt.addChild("left", ModelPartBuilder.create()
- .uv(0, 5)
- .cuboid(0.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f),
- ModelTransform.of(4.0f, 0.0f, -2.0f,
- 0.0f, 0.0f, 1.309f));
-
- skirt.addChild("front", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-4.0f, 0.0f, -5.0f, 8.0f, 0.0f, 5.0f),
- ModelTransform.of(0.0f, 0.0f, -4.0f,
- 1.309f, 0.0f, 0.0f));
-
- skirt.addChild("back", ModelPartBuilder.create()
- .uv(0, 0)
- .cuboid(-4.0f, 0.0f, 0.0f, 8.0f, 0.0f, 5.0f),
- ModelTransform.of(0.0f, 0.0f, 0.0f,
- -1.309f, 0.0f, 0.0f));
-
-
- return TexturedModelData.of(modelData, 32, 16);
- }
-
- @Override
- public void setAngles(E entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
-
- }
-
- @Override
- protected Iterable getHeadParts() {
- return ImmutableList.of();
- }
-
- @Override
- protected Iterable getBodyParts() {
- return ImmutableList.of(this.skirt);
- }
-}
\ No newline at end of file
+ private final ModelPart skirt;
+
+ public KuspukSkirtModel(@NotNull ModelPart modelPart) {
+ this.skirt = modelPart.getChild("skirt");
+ }
+
+ public static @NotNull TexturedModelData getTexturedModelData() {
+ ModelData modelData = new ModelData();
+ ModelPartData modelPartData = modelData.getRoot();
+ ModelPartData skirt = modelPartData.addChild("skirt", ModelPartBuilder.create(),
+ ModelTransform.pivot(0.0f, 18.0f, 2.0f));
+
+ skirt.addChild("strip_1", ModelPartBuilder.create()
+ .uv(0, 9)
+ .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f),
+ ModelTransform.of(3.7f, 0.0f, -0.3f,
+ -1.309f, 0.7854f, 0.0f));
+
+ skirt.addChild("strip_2", ModelPartBuilder.create()
+ .uv(0, 9)
+ .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f),
+ ModelTransform.of(-3.7f, 0.0f, -3.7f,
+ 1.309f, 0.7854f, 0.0f));
+
+ skirt.addChild("strip_3", ModelPartBuilder.create()
+ .uv(0, 9)
+ .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f),
+ ModelTransform.of(-3.7f, 0.0f, -0.3f,
+ -1.309f, -0.7854f, 0.0f));
+
+ skirt.addChild("strip_4", ModelPartBuilder.create()
+ .uv(0, 9)
+ .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f),
+ ModelTransform.of(3.7f, 0.0f, -3.7f,
+ 1.309f, -0.7854f, 0.0f));
+
+ skirt.addChild("right", ModelPartBuilder.create()
+ .uv(0, 5)
+ .cuboid(-5.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f),
+ ModelTransform.of(-4.0f, 0.0f, -2.0f,
+ 0.0f, 0.0f, -1.309f));
+
+ skirt.addChild("left", ModelPartBuilder.create()
+ .uv(0, 5)
+ .cuboid(0.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f),
+ ModelTransform.of(4.0f, 0.0f, -2.0f,
+ 0.0f, 0.0f, 1.309f));
+
+ skirt.addChild("front", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-4.0f, 0.0f, -5.0f, 8.0f, 0.0f, 5.0f),
+ ModelTransform.of(0.0f, 0.0f, -4.0f,
+ 1.309f, 0.0f, 0.0f));
+
+ skirt.addChild("back", ModelPartBuilder.create()
+ .uv(0, 0)
+ .cuboid(-4.0f, 0.0f, 0.0f, 8.0f, 0.0f, 5.0f),
+ ModelTransform.of(0.0f, 0.0f, 0.0f,
+ -1.309f, 0.0f, 0.0f));
+
+ return TexturedModelData.of(modelData, 32, 16);
+ }
+
+ @Override
+ public void setAngles(E entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
+ }
+
+ @Override
+ protected Iterable getHeadParts() {
+ return ImmutableList.of();
+ }
+
+ @Override
+ protected Iterable getBodyParts() {
+ return ImmutableList.of(this.skirt);
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java
index 7d7287eb..a5c03ed7 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java
@@ -1,43 +1,48 @@
package com.github.platymemo.alaskanativecraft.client.model.entity.feature;
import com.google.common.collect.ImmutableList;
-import net.minecraft.client.model.*;
+import org.jetbrains.annotations.NotNull;
+
+import net.minecraft.client.model.ModelData;
+import net.minecraft.client.model.ModelPart;
+import net.minecraft.client.model.ModelPartBuilder;
+import net.minecraft.client.model.ModelPartData;
+import net.minecraft.client.model.ModelTransform;
+import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.AnimalModel;
import net.minecraft.entity.LivingEntity;
-import org.jetbrains.annotations.NotNull;
public class SnowshoeModel extends AnimalModel {
- private final ModelPart snowshoe;
-
- public SnowshoeModel(@NotNull ModelPart root) {
- snowshoe = root.getChild("shoe");
- }
-
- public static @NotNull TexturedModelData getTexturedModelData() {
- ModelData modelData = new ModelData();
- ModelPartData modelPartData = modelData.getRoot();
- modelPartData.addChild("shoe", ModelPartBuilder.create()
- .uv(23, 5).cuboid(-1.0F, -24.0F, 8.0F, 2.0F, 1.0F, 5.0F)
- .uv(23, 0).cuboid(-2.0F, -24.0F, 4.0F, 4.0F, 1.0F, 4.0F)
- .uv(0, 0).cuboid(-3.0F, -24.0F, -7.0F, 6.0F, 1.0F, 11.0F)
- .uv(0, 0).cuboid(-2.0F, -24.0F, -8.0F, 4.0F, 1.0F, 1.0F)
- .uv(0, 9).cuboid(-1.0F, -24.0F, -10.0F, 2.0F, 1.0F, 2.0F),
- ModelTransform.NONE);
- return TexturedModelData.of(modelData, 64, 16);
- }
-
- @Override
- public void setAngles(E entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
-
- }
-
- @Override
- protected Iterable getHeadParts() {
- return ImmutableList.of();
- }
-
- @Override
- protected Iterable getBodyParts() {
- return ImmutableList.of(this.snowshoe);
- }
-}
\ No newline at end of file
+ private final ModelPart snowshoe;
+
+ public SnowshoeModel(@NotNull ModelPart root) {
+ this.snowshoe = root.getChild("shoe");
+ }
+
+ public static @NotNull TexturedModelData getTexturedModelData() {
+ ModelData modelData = new ModelData();
+ ModelPartData modelPartData = modelData.getRoot();
+ modelPartData.addChild("shoe", ModelPartBuilder.create()
+ .uv(23, 5).cuboid(-1.0F, -24.0F, 8.0F, 2.0F, 1.0F, 5.0F)
+ .uv(23, 0).cuboid(-2.0F, -24.0F, 4.0F, 4.0F, 1.0F, 4.0F)
+ .uv(0, 0).cuboid(-3.0F, -24.0F, -7.0F, 6.0F, 1.0F, 11.0F)
+ .uv(0, 0).cuboid(-2.0F, -24.0F, -8.0F, 4.0F, 1.0F, 1.0F)
+ .uv(0, 9).cuboid(-1.0F, -24.0F, -10.0F, 2.0F, 1.0F, 2.0F),
+ ModelTransform.NONE);
+ return TexturedModelData.of(modelData, 64, 16);
+ }
+
+ @Override
+ public void setAngles(E entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
+ }
+
+ @Override
+ protected Iterable getHeadParts() {
+ return ImmutableList.of();
+ }
+
+ @Override
+ protected Iterable getBodyParts() {
+ return ImmutableList.of(this.snowshoe);
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java
index 03e485e7..2a584d05 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java
@@ -4,6 +4,8 @@
import com.github.platymemo.alaskanativecraft.block.entity.DryingRackBlockEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
@@ -14,38 +16,35 @@
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3f;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class DryingRackBlockEntityRenderer implements BlockEntityRenderer {
- public DryingRackBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {
-
- }
-
- @Override
- public void render(@NotNull DryingRackBlockEntity dryingRackBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
- Direction.Axis axis = dryingRackBlockEntity.getCachedState().get(DryingRackBlock.AXIS);
- DefaultedList defaultedList = dryingRackBlockEntity.getItemsBeingDried();
- // Returns 0 if axis=X, 1 if axis=Z
- int XOrZ = axis.choose(0, 0, 1);
- int k = (int) dryingRackBlockEntity.getPos().asLong();
+ public DryingRackBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {
+ }
- for (int l = 0; l < defaultedList.size(); ++l) {
- ItemStack itemStack = defaultedList.get(l);
- if (itemStack != ItemStack.EMPTY) {
- matrixStack.push();
- matrixStack.translate(0.5D, 0.45D, 0.5D);
- Direction direction2 = Direction.fromHorizontal((l % 2) * 2 + XOrZ);
- float g = -direction2.asRotation();
- matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(g));
- matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
- matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
- matrixStack.translate(-0.25D, 0.1D, 0.075D * (l < 1 || l > 2 ? 1 : -1));
- matrixStack.scale(0.375F, 0.375F, 0.375F);
- MinecraftClient.getInstance().getItemRenderer().renderItem(itemStack, ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider, k + l);
- matrixStack.pop();
- }
- }
+ @Override
+ public void render(@NotNull DryingRackBlockEntity dryingRackBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
+ Direction.Axis axis = dryingRackBlockEntity.getCachedState().get(DryingRackBlock.AXIS);
+ DefaultedList defaultedList = dryingRackBlockEntity.getItemsBeingDried();
+ // Returns 0 if axis=X, 1 if axis=Z
+ int XOrZ = axis.choose(0, 0, 1);
+ int k = (int) dryingRackBlockEntity.getPos().asLong();
- }
+ for (int l = 0; l < defaultedList.size(); ++l) {
+ ItemStack itemStack = defaultedList.get(l);
+ if (itemStack != ItemStack.EMPTY) {
+ matrixStack.push();
+ matrixStack.translate(0.5D, 0.45D, 0.5D);
+ Direction direction2 = Direction.fromHorizontal((l % 2) * 2 + XOrZ);
+ float g = -direction2.asRotation();
+ matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(g));
+ matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
+ matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
+ matrixStack.translate(-0.25D, 0.1D, 0.075D * (l < 1 || l > 2 ? 1 : -1));
+ matrixStack.scale(0.375F, 0.375F, 0.375F);
+ MinecraftClient.getInstance().getItemRenderer().renderItem(itemStack, ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider, k + l);
+ matrixStack.pop();
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java
index 30b88993..8a09d1a0 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java
@@ -6,11 +6,14 @@
import com.github.platymemo.alaskanativecraft.entity.DogsledEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
@@ -18,64 +21,63 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3f;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class DogsledEntityRenderer extends EntityRenderer {
- private static final Identifier[] TEXTURES = new Identifier[]{new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/oak.png"),
- new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/spruce.png"),
- new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/birch.png"),
- new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/jungle.png"),
- new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/acacia.png"),
- new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/dark_oak.png")};
- protected final DogsledEntityModel model;
+ private static final Identifier[] TEXTURES = new Identifier[] {new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/oak.png"),
+ new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/spruce.png"),
+ new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/birch.png"),
+ new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/jungle.png"),
+ new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/acacia.png"),
+ new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/dark_oak.png")};
+ protected final DogsledEntityModel model;
- public DogsledEntityRenderer(EntityRendererFactory.Context ctx) {
- super(ctx);
- this.model = new DogsledEntityModel(ctx.getPart(AlaskaModels.DOGSLED));
- this.shadowRadius = 0.5F;
- }
+ public DogsledEntityRenderer(EntityRendererFactory.Context ctx) {
+ super(ctx);
+ this.model = new DogsledEntityModel(ctx.getPart(AlaskaModels.DOGSLED));
+ this.shadowRadius = 0.5F;
+ }
- @Override
- public void render(@NotNull DogsledEntity dogsledEntity, float yaw, float tickDelta, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light) {
- matrixStack.push();
- matrixStack.scale(1.5F, 1.5F, 1.5F);
- matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(270 - yaw));
- float h = (float) dogsledEntity.getDamageWobbleTicks() - tickDelta;
- float j = dogsledEntity.getDamageWobbleStrength() - tickDelta;
- if (j < 0.0F) {
- j = 0.0F;
- }
+ @Override
+ public void render(@NotNull DogsledEntity dogsledEntity, float yaw, float tickDelta, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light) {
+ matrixStack.push();
+ matrixStack.scale(1.5F, 1.5F, 1.5F);
+ matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(270 - yaw));
+ float h = (float) dogsledEntity.getDamageWobbleTicks() - tickDelta;
+ float j = dogsledEntity.getDamageWobbleStrength() - tickDelta;
+ if (j < 0.0F) {
+ j = 0.0F;
+ }
- if (h > 0.0F) {
- matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(MathHelper.sin(h) * h * j / 10.0F * (float) dogsledEntity.getDamageWobbleSide()));
- }
+ if (h > 0.0F) {
+ matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(MathHelper.sin(h) * h * j / 10.0F * (float) dogsledEntity.getDamageWobbleSide()));
+ }
- // Chest Rendering
- matrixStack.push();
- float s = 0.5F;
- matrixStack.scale(s, s, s);
- matrixStack.translate(-0.3D, 0.6D, 0.5D);
- matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F));
- this.renderBlock(Blocks.CHEST.getDefaultState(), matrixStack, vertexConsumerProvider, light);
- matrixStack.pop();
+ // Chest Rendering
+ matrixStack.push();
+ float s = 0.5F;
+ matrixStack.scale(s, s, s);
+ matrixStack.translate(-0.3D, 0.6D, 0.5D);
+ matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F));
+ this.renderBlock(Blocks.CHEST.getDefaultState(), matrixStack, vertexConsumerProvider, light);
+ matrixStack.pop();
- matrixStack.scale(-1.0F, -1.0F, 1.0F);
- matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F));
- this.model.setAngles(dogsledEntity, tickDelta, 0.0F, -0.1F, 0.0F, 0.0F);
- VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(this.model.getLayer(this.getTexture(dogsledEntity)));
- this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
+ matrixStack.scale(-1.0F, -1.0F, 1.0F);
+ matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F));
+ this.model.setAngles(dogsledEntity, tickDelta, 0.0F, -0.1F, 0.0F, 0.0F);
+ VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(this.model.getLayer(this.getTexture(dogsledEntity)));
+ this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
- matrixStack.pop();
- super.render(dogsledEntity, yaw, tickDelta, matrixStack, vertexConsumerProvider, light);
- }
+ matrixStack.pop();
+ super.render(dogsledEntity, yaw, tickDelta, matrixStack, vertexConsumerProvider, light);
+ }
- @Override
- public Identifier getTexture(@NotNull DogsledEntity dogsledEntity) {
- return TEXTURES[dogsledEntity.getDogsledType().ordinal()];
- }
+ @Override
+ public Identifier getTexture(@NotNull DogsledEntity dogsledEntity) {
+ return TEXTURES[dogsledEntity.getDogsledType().ordinal()];
+ }
- protected void renderBlock(BlockState state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
- MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(state, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV);
- }
+ protected void renderBlock(BlockState state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
+ MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(state, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV);
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java
index 99ba8046..bddae9a8 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java
@@ -1,11 +1,17 @@
package com.github.platymemo.alaskanativecraft.client.renderer.entity;
+import java.util.HashMap;
+import java.util.Map;
+
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels;
import com.github.platymemo.alaskanativecraft.client.model.entity.HarpoonEntityModel;
import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
@@ -16,44 +22,41 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.registry.Registry;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.HashMap;
-import java.util.Map;
public class HarpoonEntityRenderer extends EntityRenderer {
- private static final Map, Identifier> TEXTURES = new HashMap<>();
- private final HarpoonEntityModel model;
-
- public HarpoonEntityRenderer(EntityRendererFactory.Context ctx) {
- super(ctx);
- model = new HarpoonEntityModel(ctx.getPart(AlaskaModels.HARPOON));
- }
-
- public static Identifier getTexture(EntityType> type) {
- if (!TEXTURES.containsKey(type)) {
- TEXTURES.put(type, new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/harpoon/" + Registry.ENTITY_TYPE.getId(type).getPath() + ".png"));
- }
- return TEXTURES.get(type);
- }
-
- @Override
- public void render(@NotNull HarpoonEntity harpoon, float f, float g, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
- matrixStack.push();
- {
- matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevYaw, harpoon.getYaw()) - 90.0F));
- matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevPitch, harpoon.getPitch()) + 90.0F));
- VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, model.getLayer(this.getTexture(harpoon)), false, harpoon.isEnchanted());
- model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
- matrixStack.scale(2.0F, -2.0F, -2.0F);
- }
- matrixStack.pop();
- super.render(harpoon, f, g, matrixStack, vertexConsumerProvider, i);
- }
-
- @Override
- public Identifier getTexture(@NotNull HarpoonEntity harpoon) {
- return getTexture(harpoon.getType());
- }
+ private static final Map, Identifier> TEXTURES = new HashMap<>();
+ private final HarpoonEntityModel model;
+
+ public HarpoonEntityRenderer(EntityRendererFactory.Context ctx) {
+ super(ctx);
+ this.model = new HarpoonEntityModel(ctx.getPart(AlaskaModels.HARPOON));
+ }
+
+ public static Identifier getTexture(EntityType> type) {
+ if (!TEXTURES.containsKey(type)) {
+ TEXTURES.put(type, new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/harpoon/" + Registry.ENTITY_TYPE.getId(type).getPath() + ".png"));
+ }
+
+ return TEXTURES.get(type);
+ }
+
+ @Override
+ public void render(@NotNull HarpoonEntity harpoon, float f, float g, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
+ matrixStack.push();
+ {
+ matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevYaw, harpoon.getYaw()) - 90.0F));
+ matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevPitch, harpoon.getPitch()) + 90.0F));
+ VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, this.model.getLayer(this.getTexture(harpoon)), false, harpoon.isEnchanted());
+ this.model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
+ matrixStack.scale(2.0F, -2.0F, -2.0F);
+ }
+
+ matrixStack.pop();
+ super.render(harpoon, f, g, matrixStack, vertexConsumerProvider, i);
+ }
+
+ @Override
+ public Identifier getTexture(@NotNull HarpoonEntity harpoon) {
+ return getTexture(harpoon.getType());
+ }
}
-
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java
index adf3d198..6c727f93 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java
@@ -6,6 +6,7 @@
import com.github.platymemo.alaskanativecraft.entity.MooseEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
@@ -13,20 +14,20 @@
@Environment(EnvType.CLIENT)
public class MooseEntityRenderer extends MobEntityRenderer> {
- private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/moose.png");
+ private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/moose.png");
- public MooseEntityRenderer(EntityRendererFactory.Context ctx) {
- super(ctx, new MooseEntityModel<>(ctx.getPart(AlaskaModels.MOOSE)), 1.5F);
- }
+ public MooseEntityRenderer(EntityRendererFactory.Context ctx) {
+ super(ctx, new MooseEntityModel<>(ctx.getPart(AlaskaModels.MOOSE)), 1.5F);
+ }
- @Override
- public Identifier getTexture(MooseEntity mooseEntity) {
- return TEXTURE;
- }
+ @Override
+ public Identifier getTexture(MooseEntity mooseEntity) {
+ return TEXTURE;
+ }
- @Override
- protected void scale(MooseEntity entity, MatrixStack matrices, float amount) {
- super.scale(entity, matrices, amount);
- matrices.scale(2.0F, 2.0F, 2.0F);
- }
-}
\ No newline at end of file
+ @Override
+ protected void scale(MooseEntity entity, MatrixStack matrices, float amount) {
+ super.scale(entity, matrices, amount);
+ matrices.scale(2.0F, 2.0F, 2.0F);
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java
index d08a09a4..7f429807 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java
@@ -6,31 +6,32 @@
import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class PtarmiganEntityRenderer extends MobEntityRenderer {
- public static final Identifier[] TEXTURES = {new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/ptarmigan.png"),
- new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/brown_ptarmigan.png"),
- new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/grey_ptarmigan.png")};
+ public static final Identifier[] TEXTURES = {new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/ptarmigan.png"),
+ new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/brown_ptarmigan.png"),
+ new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/grey_ptarmigan.png")};
- public PtarmiganEntityRenderer(EntityRendererFactory.Context ctx) {
- super(ctx, new PtarmiganEntityModel(ctx.getPart(AlaskaModels.PTARMIGAN)), 0.3F);
- }
+ public PtarmiganEntityRenderer(EntityRendererFactory.Context ctx) {
+ super(ctx, new PtarmiganEntityModel(ctx.getPart(AlaskaModels.PTARMIGAN)), 0.3F);
+ }
- @Override
- public Identifier getTexture(@NotNull PtarmiganEntity ptarmiganEntity) {
- return TEXTURES[ptarmiganEntity.getPtarmiganType()];
- }
+ @Override
+ public Identifier getTexture(@NotNull PtarmiganEntity ptarmiganEntity) {
+ return TEXTURES[ptarmiganEntity.getPtarmiganType()];
+ }
- @Override
- public float getAnimationProgress(@NotNull PtarmiganEntity ptarmiganEntity, float f) {
- float g = MathHelper.lerp(f, ptarmiganEntity.prevFlapProgress, ptarmiganEntity.flapProgress);
- float h = MathHelper.lerp(f, ptarmiganEntity.prevMaxWingDeviation, ptarmiganEntity.maxWingDeviation);
- return (MathHelper.sin(g) + 1.0F) * h;
- }
+ @Override
+ public float getAnimationProgress(@NotNull PtarmiganEntity ptarmiganEntity, float f) {
+ float g = MathHelper.lerp(f, ptarmiganEntity.prevFlapProgress, ptarmiganEntity.flapProgress);
+ float h = MathHelper.lerp(f, ptarmiganEntity.prevMaxWingDeviation, ptarmiganEntity.maxWingDeviation);
+ return (MathHelper.sin(g) + 1.0F) * h;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java
index be1ca8a2..817cefe3 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java
@@ -6,20 +6,21 @@
import com.github.platymemo.alaskanativecraft.entity.SealEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT)
public class SealEntityRenderer extends MobEntityRenderer> {
- private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/seal/seal.png");
+ private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/seal/seal.png");
- public SealEntityRenderer(EntityRendererFactory.Context ctx) {
- super(ctx, new SealEntityModel<>(ctx.getPart(AlaskaModels.SEAL)), 0.7F);
- }
+ public SealEntityRenderer(EntityRendererFactory.Context ctx) {
+ super(ctx, new SealEntityModel<>(ctx.getPart(AlaskaModels.SEAL)), 0.7F);
+ }
- @Override
- public Identifier getTexture(SealEntity sealEntity) {
- return TEXTURE;
- }
-}
\ No newline at end of file
+ @Override
+ public Identifier getTexture(SealEntity sealEntity) {
+ return TEXTURE;
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java
index 74d2cbbc..19e97042 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java
@@ -6,9 +6,12 @@
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
-import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
@@ -20,37 +23,37 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class KuspukSkirtFeatureRenderer> extends FeatureRenderer {
- private final KuspukSkirtModel model;
- private final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/skirt_layer.png");
+ private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/skirt_layer.png");
+ private final KuspukSkirtModel model;
+
+ public KuspukSkirtFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) {
+ super(context);
+ this.model = new KuspukSkirtModel<>(loader.getModelPart(AlaskaModels.KUSPUK_SKIRT));
+ }
- public KuspukSkirtFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) {
- super(context);
- this.model = new KuspukSkirtModel<>(loader.getModelPart(AlaskaModels.KUSPUK_SKIRT));
- }
+ @Override
+ public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E livingEntity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
+ ItemStack armorItemStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST);
+ if (armorItemStack.isOf(AlaskaItems.KUSPUK_BODY)) {
+ int color = AlaskaItems.KUSPUK_BODY.getColor(armorItemStack);
+ float r = (float) (color >> 16 & 255) / 255.0F;
+ float g = (float) (color >> 8 & 255) / 255.0F;
+ float b = (float) (color & 255) / 255.0F;
+ matrixStack.push();
+ if (livingEntity.isInSneakingPose()) {
+ matrixStack.translate(0.0D, -2.55D, 0.3D);
+ } else {
+ matrixStack.translate(0.0D, -2.7D, 0.0D);
+ }
- @Override
- public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E livingEntity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
- ItemStack armorItemStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST);
- if (armorItemStack.isOf(AlaskaItems.KUSPUK_BODY)) {
- int color = AlaskaItems.KUSPUK_BODY.getColor(armorItemStack);
- float r = (float) (color >> 16 & 255) / 255.0F;
- float g = (float) (color >> 8 & 255) / 255.0F;
- float b = (float) (color & 255) / 255.0F;
- matrixStack.push();
- if (livingEntity.isInSneakingPose()) {
- matrixStack.translate(0.0D, -2.55D, 0.3D);
- } else {
- matrixStack.translate(0.0D, -2.7D, 0.0D);
- }
- matrixStack.scale(2.5F, 2.5F, 2.5F);
- VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint());
- this.model.setAngles(livingEntity, limbAngle, limbDistance, animationProgress, headYaw, headPitch);
- this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, r, g, b, 1.0F);
- matrixStack.pop();
- }
- }
+ matrixStack.scale(2.5F, 2.5F, 2.5F);
+ VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint());
+ this.model.setAngles(livingEntity, limbAngle, limbDistance, animationProgress, headYaw, headPitch);
+ this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, r, g, b, 1.0F);
+ matrixStack.pop();
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java
index e5a9879a..c781e8d5 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java
@@ -6,8 +6,11 @@
import com.github.platymemo.alaskanativecraft.entity.AlaskaEntities;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.render.OverlayTexture;
-import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
@@ -17,31 +20,30 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class ShoulderPtarmiganFeatureRenderer extends FeatureRenderer> {
- private final PtarmiganEntityModel model;
+ private final PtarmiganEntityModel model;
- public ShoulderPtarmiganFeatureRenderer(FeatureRendererContext> context, @NotNull EntityModelLoader loader) {
- super(context);
- this.model = new PtarmiganEntityModel(loader.getModelPart(AlaskaModels.PTARMIGAN));
- }
+ public ShoulderPtarmiganFeatureRenderer(FeatureRendererContext> context, @NotNull EntityModelLoader loader) {
+ super(context);
+ this.model = new PtarmiganEntityModel(loader.getModelPart(AlaskaModels.PTARMIGAN));
+ }
- @Override
- public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T playerEntity, float f, float g, float h, float j, float k, float l) {
- this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, true);
- this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, false);
- }
+ @Override
+ public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T playerEntity, float f, float g, float h, float j, float k, float l) {
+ this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, true);
+ this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, false);
+ }
- private void renderShoulderPtarmigan(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T player, float limbAngle, float limbDistance, float headYaw, float headPitch, boolean leftShoulder) {
- NbtCompound compoundTag = leftShoulder ? player.getShoulderEntityLeft() : player.getShoulderEntityRight();
- EntityType.get(compoundTag.getString("id")).filter((entityType) -> entityType == AlaskaEntities.PTARMIGAN).ifPresent((entityType) -> {
- matrices.push();
- matrices.translate(leftShoulder ? 0.4D : -0.4D, player.isInSneakingPose() ? -1.3D : -1.5D, 0.0D);
- VertexConsumer vertexConsumer = vertexConsumers.getBuffer(this.model.getLayer(PtarmiganEntityRenderer.TEXTURES[compoundTag.getInt("Type")]));
- this.model.poseOnShoulder(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, limbAngle, limbDistance, headYaw, headPitch, player.age);
- matrices.pop();
- });
- }
+ private void renderShoulderPtarmigan(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T player, float limbAngle, float limbDistance, float headYaw, float headPitch, boolean leftShoulder) {
+ NbtCompound compoundTag = leftShoulder ? player.getShoulderEntityLeft() : player.getShoulderEntityRight();
+ EntityType.get(compoundTag.getString("id")).filter((entityType) -> entityType == AlaskaEntities.PTARMIGAN).ifPresent((entityType) -> {
+ matrices.push();
+ matrices.translate(leftShoulder ? 0.4D : -0.4D, player.isInSneakingPose() ? -1.3D : -1.5D, 0.0D);
+ VertexConsumer vertexConsumer = vertexConsumers.getBuffer(this.model.getLayer(PtarmiganEntityRenderer.TEXTURES[compoundTag.getInt("Type")]));
+ this.model.poseOnShoulder(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, limbAngle, limbDistance, headYaw, headPitch, player.age);
+ matrices.pop();
+ });
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java
index 9d7b02da..5a965323 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java
@@ -6,9 +6,12 @@
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
-import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
@@ -22,65 +25,62 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class SnowshoeFeatureRenderer> extends FeatureRenderer {
- public static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/snowshoe.png");
- private final SnowshoeModel model;
+ public static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/snowshoe.png");
+ private final SnowshoeModel model;
+
+ public SnowshoeFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) {
+ super(context);
+ this.model = new SnowshoeModel<>(loader.getModelPart(AlaskaModels.SNOWSHOES));
+ }
+
+ @Override
+ public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
+ ItemStack armorItemStack = entity.getEquippedStack(EquipmentSlot.FEET);
+ if (armorItemStack.isOf(AlaskaItems.SNOWSHOES)) {
+ VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint());
- public SnowshoeFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) {
- super(context);
- this.model = new SnowshoeModel<>(loader.getModelPart(AlaskaModels.SNOWSHOES));
- }
+ matrices.push();
+ this.translateToRightLeg(matrices, this.getContextModel(), entity);
+ this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
+ matrices.pop();
- @Override
- public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
- ItemStack armorItemStack = entity.getEquippedStack(EquipmentSlot.FEET);
- if (armorItemStack.isOf(AlaskaItems.SNOWSHOES)) {
- VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint());
+ matrices.push();
+ this.translateToLeftLeg(matrices, this.getContextModel(), entity);
+ this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
+ matrices.pop();
+ }
+ }
- matrices.push();
- {
- this.translateToRightLeg(matrices, this.getContextModel(), entity);
- this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
- }
- matrices.pop();
+ private void translateToRightLeg(MatrixStack matrices, M model, @NotNull E entity) {
+ if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) {
+ matrices.translate(0.0F, 0.0F, 0.25F);
+ }
- matrices.push();
- {
- this.translateToLeftLeg(matrices, this.getContextModel(), entity);
- this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
- }
- matrices.pop();
- }
- }
+ matrices.translate(-0.115F, 0.75F, 0.0F);
+ matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.rightLeg.roll));
+ matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.rightLeg.yaw));
+ matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.rightLeg.pitch));
+ // This sets it just above the armor stand base.
+ float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F;
+ matrices.translate(0.0F, bottomOfFoot, 0.0F);
+ matrices.scale(2.0F, 2.0F, 2.0F);
+ }
- private void translateToRightLeg(MatrixStack matrices, M model, @NotNull E entity) {
- if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) {
- matrices.translate(0.0F, 0.0F, 0.25F);
- }
- matrices.translate(-0.115F, 0.75F, 0.0F);
- matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.rightLeg.roll));
- matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.rightLeg.yaw));
- matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.rightLeg.pitch));
- // This sets it just above the armor stand base.
- float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F;
- matrices.translate(0.0F, bottomOfFoot, 0.0F);
- matrices.scale(2.0F, 2.0F, 2.0F);
- }
+ private void translateToLeftLeg(MatrixStack matrices, M model, @NotNull E entity) {
+ if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) {
+ matrices.translate(0.0F, 0.0F, 0.25F);
+ }
- private void translateToLeftLeg(MatrixStack matrices, M model, @NotNull E entity) {
- if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) {
- matrices.translate(0.0F, 0.0F, 0.25F);
- }
- matrices.translate(0.115F, 0.75F, 0.0F);
- matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.leftLeg.roll));
- matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.leftLeg.yaw));
- matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.leftLeg.pitch));
- // This sets it just above the armor stand base.
- float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F;
- matrices.translate(0.0F, bottomOfFoot, 0.0F);
- matrices.scale(2.0F, 2.0F, 2.0F);
- }
+ matrices.translate(0.115F, 0.75F, 0.0F);
+ matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.leftLeg.roll));
+ matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.leftLeg.yaw));
+ matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.leftLeg.pitch));
+ // This sets it just above the armor stand base.
+ float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F;
+ matrices.translate(0.0F, bottomOfFoot, 0.0F);
+ matrices.scale(2.0F, 2.0F, 2.0F);
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java
index 97067062..f149fb9e 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java
@@ -5,7 +5,9 @@
import com.github.platymemo.alaskanativecraft.item.HarpoonItem;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.render.VertexConsumer;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
@@ -17,37 +19,37 @@
@Environment(EnvType.CLIENT)
public enum HarpoonItemRenderer {
- INSTANCE;
- private final HarpoonEntityModel harpoonEntityModel = new HarpoonEntityModel(HarpoonEntityModel.getTexturedModelData().createModel());
-
- public boolean render(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) {
- if (renderMode == ModelTransformation.Mode.GUI || renderMode == ModelTransformation.Mode.GROUND || renderMode == ModelTransformation.Mode.FIXED) {
- return false;
- }
-
- matrices.push();
- {
- model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices);
-
- if (entity != null && entity.isUsingItem() && entity.getActiveItem() == stack && (renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND)) {
- matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180));
- matrices.translate(0, 2, 0);
- } else {
- matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
- matrices.translate(0, 0.85, 0);
- }
-
- matrices.scale(2.0F, -2.0F, -2.0F);
- VertexConsumer harpoon = ItemRenderer.getArmorGlintConsumer(
- vertexConsumers,
- this.harpoonEntityModel.getLayer(HarpoonEntityRenderer.getTexture(((HarpoonItem) stack.getItem()).getType())),
- false,
- stack.hasGlint()
- );
- this.harpoonEntityModel.render(matrices, harpoon, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
-
- }
- matrices.pop();
- return true;
- }
+ INSTANCE;
+ private final HarpoonEntityModel harpoonEntityModel = new HarpoonEntityModel(HarpoonEntityModel.getTexturedModelData().createModel());
+
+ public boolean render(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) {
+ if (renderMode == ModelTransformation.Mode.GUI || renderMode == ModelTransformation.Mode.GROUND || renderMode == ModelTransformation.Mode.FIXED) {
+ return false;
+ }
+
+ matrices.push();
+ {
+ model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices);
+
+ if (entity != null && entity.isUsingItem() && entity.getActiveItem() == stack && (renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND)) {
+ matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180));
+ matrices.translate(0, 2, 0);
+ } else {
+ matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
+ matrices.translate(0, 0.85, 0);
+ }
+
+ matrices.scale(2.0F, -2.0F, -2.0F);
+ VertexConsumer harpoon = ItemRenderer.getArmorGlintConsumer(
+ vertexConsumers,
+ this.harpoonEntityModel.getLayer(HarpoonEntityRenderer.getTexture(((HarpoonItem) stack.getItem()).getType())),
+ false,
+ stack.hasGlint()
+ );
+ this.harpoonEntityModel.render(matrices, harpoon, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
+ }
+
+ matrices.pop();
+ return true;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java
index d011121f..29c2489d 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java
@@ -4,7 +4,10 @@
import com.github.platymemo.alaskanativecraft.client.renderer.entity.feature.SnowshoeFeatureRenderer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.render.VertexConsumer;
+import org.jetbrains.annotations.NotNull;
+
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
@@ -13,37 +16,37 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Vec3f;
-import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public enum SnowshoeItemRenderer {
- INSTANCE;
- private final SnowshoeModel snowshoeModel = new SnowshoeModel<>(SnowshoeModel.getTexturedModelData().createModel());
-
- public boolean render(ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, @NotNull MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, @NotNull BakedModel model) {
- matrices.push();
- {
- model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices);
-
- if (renderMode.isFirstPerson() || renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND) {
- matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90));
- matrices.translate(0, -0.05, -0.15);
- matrices.scale(2.0F, 2.0F, 2.0F);
- } else {
- matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90));
- matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(45));
- matrices.scale(1.5F, 1.5F, 1.5F);
- }
-
- VertexConsumer snowshoe = ItemRenderer.getArmorGlintConsumer(
- vertexConsumers,
- this.snowshoeModel.getLayer(SnowshoeFeatureRenderer.TEXTURE),
- false,
- stack.hasGlint()
- );
- this.snowshoeModel.render(matrices, snowshoe, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
- }
- matrices.pop();
- return true;
- }
+ INSTANCE;
+ private final SnowshoeModel snowshoeModel = new SnowshoeModel<>(SnowshoeModel.getTexturedModelData().createModel());
+
+ public boolean render(ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, @NotNull MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, @NotNull BakedModel model) {
+ matrices.push();
+ {
+ model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices);
+
+ if (renderMode.isFirstPerson() || renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND) {
+ matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90));
+ matrices.translate(0, -0.05, -0.15);
+ matrices.scale(2.0F, 2.0F, 2.0F);
+ } else {
+ matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90));
+ matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(45));
+ matrices.scale(1.5F, 1.5F, 1.5F);
+ }
+
+ VertexConsumer snowshoe = ItemRenderer.getArmorGlintConsumer(
+ vertexConsumers,
+ this.snowshoeModel.getLayer(SnowshoeFeatureRenderer.TEXTURE),
+ false,
+ stack.hasGlint()
+ );
+ this.snowshoeModel.render(matrices, snowshoe, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
+ }
+
+ matrices.pop();
+ return true;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java
index ff968857..9f3a0361 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java
@@ -9,8 +9,8 @@
@Environment(EnvType.CLIENT)
public class AlaskaModMenu implements ModMenuApi {
- @Override
- public ConfigScreenFactory> getModConfigScreenFactory() {
- return parent -> AutoConfig.getConfigScreen(AlaskaConfig.class, parent).get();
- }
+ @Override
+ public ConfigScreenFactory> getModConfigScreenFactory() {
+ return parent -> AutoConfig.getConfigScreen(AlaskaConfig.class, parent).get();
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java
index 27eea804..a3e56e61 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java
@@ -10,36 +10,37 @@
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.client.BuiltinClientPlugin;
-import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
+import net.minecraft.text.Text;
+
public class AlaskaPlugin implements REIClientPlugin {
- public static final CategoryIdentifier DRYING_ID = CategoryIdentifier.of(AlaskaNativeCraft.MOD_ID, "plugins/drying");
+ public static final CategoryIdentifier DRYING_ID = CategoryIdentifier.of(AlaskaNativeCraft.MOD_ID, "plugins/drying");
- @Override
- public void registerCategories(@NotNull CategoryRegistry registry) {
- registry.add(new DryingCategory(), config -> config.addWorkstations(EntryStacks.of(AlaskaBlocks.DRYING_RACK)));
- }
+ @Override
+ public void registerCategories(@NotNull CategoryRegistry registry) {
+ registry.add(new DryingCategory(), config -> config.addWorkstations(EntryStacks.of(AlaskaBlocks.DRYING_RACK)));
+ }
- @Override
- public void registerDisplays(@NotNull DisplayRegistry registry) {
- registry.registerFiller(DryingRecipe.class, DryingDisplay::new);
- BuiltinClientPlugin.getInstance().registerInformation(
- EntryStacks.of(AlaskaItems.AKUTAQ),
- Text.translatable("item.alaskanativecraft.akutaq"),
- (list) -> {
- list.add(Text.translatable("alaskanativecraft.akutaq.line1"));
- list.add(Text.translatable("alaskanativecraft.akutaq.line2"));
- list.add(Text.translatable("alaskanativecraft.akutaq.line3"));
- return list;
- });
- BuiltinClientPlugin.getInstance().registerInformation(
- EntryStacks.of(AlaskaItems.FISH_STRIP),
- Text.translatable("item.alaskanativecraft.fish_strip"),
- (list) -> {
- list.add(Text.translatable("alaskanativecraft.fish_strip.line1"));
- list.add(Text.translatable("alaskanativecraft.fish_strip.line2"));
- return list;
- });
- }
+ @Override
+ public void registerDisplays(@NotNull DisplayRegistry registry) {
+ registry.registerFiller(DryingRecipe.class, DryingDisplay::new);
+ BuiltinClientPlugin.getInstance().registerInformation(
+ EntryStacks.of(AlaskaItems.AKUTAQ),
+ Text.translatable("item.alaskanativecraft.akutaq"),
+ (list) -> {
+ list.add(Text.translatable("alaskanativecraft.akutaq.line1"));
+ list.add(Text.translatable("alaskanativecraft.akutaq.line2"));
+ list.add(Text.translatable("alaskanativecraft.akutaq.line3"));
+ return list;
+ });
+ BuiltinClientPlugin.getInstance().registerInformation(
+ EntryStacks.of(AlaskaItems.FISH_STRIP),
+ Text.translatable("item.alaskanativecraft.fish_strip"),
+ (list) -> {
+ list.add(Text.translatable("alaskanativecraft.fish_strip.line1"));
+ list.add(Text.translatable("alaskanativecraft.fish_strip.line2"));
+ return list;
+ });
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java
index dc00d64b..0646ea48 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java
@@ -1,5 +1,8 @@
package com.github.platymemo.alaskanativecraft.compat.rei;
+import java.text.DecimalFormat;
+import java.util.List;
+
import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks;
import com.google.common.collect.Lists;
import me.shedaniel.math.Point;
@@ -10,46 +13,44 @@
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.util.EntryStacks;
-import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
-import java.text.DecimalFormat;
-import java.util.List;
+import net.minecraft.text.Text;
public class DryingCategory implements DisplayCategory {
- @Override
- public CategoryIdentifier extends DryingDisplay> getCategoryIdentifier() {
- return AlaskaPlugin.DRYING_ID;
- }
-
- @Override
- public @NotNull Renderer getIcon() {
- return EntryStacks.of(AlaskaBlocks.DRYING_RACK);
- }
-
- @Override
- public Text getTitle() {
- return Text.translatable("category.rei.alaskanativecraft.drying");
- }
-
- @Override
- public @NotNull List setupDisplay(@NotNull DryingDisplay display, @NotNull Rectangle bounds) {
- Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
- final double cookingTime = display.getDryTime();
- DecimalFormat df = new DecimalFormat("###.##");
- List widgets = Lists.newArrayList();
- widgets.add(Widgets.createRecipeBase(bounds));
- widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9)));
- widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5),
- Text.translatable("category.rei.campfire.time", df.format(cookingTime / 20d))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
- widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(cookingTime));
- widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 9)).entries(display.getInputEntries().get(0)).markInput());
- widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput());
- return widgets;
- }
-
- @Override
- public int getDisplayHeight() {
- return 49;
- }
+ @Override
+ public CategoryIdentifier extends DryingDisplay> getCategoryIdentifier() {
+ return AlaskaPlugin.DRYING_ID;
+ }
+
+ @Override
+ public @NotNull Renderer getIcon() {
+ return EntryStacks.of(AlaskaBlocks.DRYING_RACK);
+ }
+
+ @Override
+ public Text getTitle() {
+ return Text.translatable("category.rei.alaskanativecraft.drying");
+ }
+
+ @Override
+ public @NotNull List setupDisplay(@NotNull DryingDisplay display, @NotNull Rectangle bounds) {
+ Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
+ final double cookingTime = display.getDryTime();
+ DecimalFormat df = new DecimalFormat("###.##");
+ List widgets = Lists.newArrayList();
+ widgets.add(Widgets.createRecipeBase(bounds));
+ widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9)));
+ widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5),
+ Text.translatable("category.rei.campfire.time", df.format(cookingTime / 20d))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
+ widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(cookingTime));
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 9)).entries(display.getInputEntries().get(0)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput());
+ return widgets;
+ }
+
+ @Override
+ public int getDisplayHeight() {
+ return 49;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java
index f365bd42..5c33e4ca 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java
@@ -1,5 +1,9 @@
package com.github.platymemo.alaskanativecraft.compat.rei;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
import com.github.platymemo.alaskanativecraft.recipe.DryingRecipe;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
@@ -7,56 +11,52 @@
import me.shedaniel.rei.api.common.util.EntryIngredients;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
@Environment(EnvType.CLIENT)
public class DryingDisplay implements Display {
- private final List inputs;
- private final List output;
- private final int dryTime;
- private DryingRecipe display;
-
- public DryingDisplay(@NotNull DryingRecipe recipe) {
- this(recipe.getIngredients(), recipe.getOutput(), recipe.getCookTime());
- this.display = recipe;
- }
-
- public DryingDisplay(DefaultedList ingredients, ItemStack output, int dryTime) {
- this.inputs = EntryIngredients.ofIngredients(ingredients);
- this.output = Collections.singletonList(EntryIngredients.of(output));
- this.dryTime = dryTime;
- }
-
- public double getDryTime() {
- return dryTime;
- }
-
- @Override
- public @NotNull Optional getDisplayLocation() {
- return Optional.ofNullable(display).map(DryingRecipe::getId);
- }
-
- @Override
- public @NotNull List getInputEntries() {
- return inputs;
- }
-
- @Override
- public @NotNull List getOutputEntries() {
- return output;
- }
-
- @Override
- public CategoryIdentifier> getCategoryIdentifier() {
- return AlaskaPlugin.DRYING_ID;
- }
+ private final List inputs;
+ private final List output;
+ private final int dryTime;
+ private DryingRecipe display;
+
+ public DryingDisplay(@NotNull DryingRecipe recipe) {
+ this(recipe.getIngredients(), recipe.getOutput(), recipe.getCookTime());
+ this.display = recipe;
+ }
+
+ public DryingDisplay(DefaultedList ingredients, ItemStack output, int dryTime) {
+ this.inputs = EntryIngredients.ofIngredients(ingredients);
+ this.output = Collections.singletonList(EntryIngredients.of(output));
+ this.dryTime = dryTime;
+ }
+
+ public double getDryTime() {
+ return this.dryTime;
+ }
+
+ @Override
+ public @NotNull Optional getDisplayLocation() {
+ return Optional.ofNullable(this.display).map(DryingRecipe::getId);
+ }
+
+ @Override
+ public @NotNull List getInputEntries() {
+ return this.inputs;
+ }
+
+ @Override
+ public @NotNull List getOutputEntries() {
+ return this.output;
+ }
+
+ @Override
+ public CategoryIdentifier> getCategoryIdentifier() {
+ return AlaskaPlugin.DRYING_ID;
+ }
}
-
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java b/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java
index b34db4c5..4dcf6d1a 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java
@@ -9,73 +9,73 @@
@Config(name = AlaskaNativeCraft.MOD_ID)
public class AlaskaConfig implements ConfigData {
- @ConfigEntry.Gui.Excluded
- private transient static boolean registered = false;
- @ConfigEntry.Gui.TransitiveObject
- @ConfigEntry.Category("spawning")
- public SpawnOptions spawning = new SpawnOptions();
- @ConfigEntry.Gui.TransitiveObject
- @ConfigEntry.Category("generation")
- public GenerationOptions generation = new GenerationOptions();
+ @ConfigEntry.Gui.Excluded
+ private static boolean registered = false;
+ @ConfigEntry.Gui.TransitiveObject
+ @ConfigEntry.Category("spawning")
+ public SpawnOptions spawning = new SpawnOptions();
+ @ConfigEntry.Gui.TransitiveObject
+ @ConfigEntry.Category("generation")
+ public GenerationOptions generation = new GenerationOptions();
- public boolean snowballConversion = false;
- public boolean mooseEatBark = true;
- @ConfigEntry.Gui.CollapsibleObject
- public SealFishing sealFishing = new SealFishing();
+ public boolean snowballConversion = false;
+ public boolean mooseEatBark = true;
+ @ConfigEntry.Gui.CollapsibleObject
+ public SealFishing sealFishing = new SealFishing();
- public static synchronized AlaskaConfig getConfig() {
- if (!registered) {
- AutoConfig.register(AlaskaConfig.class, GsonConfigSerializer::new);
- registered = true;
- }
+ public static synchronized AlaskaConfig getConfig() {
+ if (!registered) {
+ AutoConfig.register(AlaskaConfig.class, GsonConfigSerializer::new);
+ registered = true;
+ }
- return AutoConfig.getConfigHolder(AlaskaConfig.class).getConfig();
- }
+ return AutoConfig.getConfigHolder(AlaskaConfig.class).getConfig();
+ }
- public static class SealFishing {
- public boolean sealsHuntFish = true;
- @ConfigEntry.Gui.Tooltip(count = 2)
- public boolean sealsEatHuntedFish = true;
- @ConfigEntry.Gui.Tooltip(count = 2)
- public boolean sealsBreedFromHuntedFish = false;
- }
+ public static class SealFishing {
+ public boolean sealsHuntFish = true;
+ @ConfigEntry.Gui.Tooltip(count = 2)
+ public boolean sealsEatHuntedFish = true;
+ @ConfigEntry.Gui.Tooltip(count = 2)
+ public boolean sealsBreedFromHuntedFish = false;
+ }
- public static class SpawnOptions {
- @ConfigEntry.Gui.CollapsibleObject
- public SpawnSettings sealOceanSettings = new SpawnSettings(5, 1, 4);
- @ConfigEntry.Gui.CollapsibleObject
- public SpawnSettings mooseSettings = new SpawnSettings(2, 1, 3);
- @ConfigEntry.Gui.CollapsibleObject
- public SpawnSettings ptarmiganSettings = new SpawnSettings(5, 2, 5);
+ public static class SpawnOptions {
+ @ConfigEntry.Gui.CollapsibleObject
+ public SpawnSettings sealOceanSettings = new SpawnSettings(5, 1, 4);
+ @ConfigEntry.Gui.CollapsibleObject
+ public SpawnSettings mooseSettings = new SpawnSettings(2, 1, 3);
+ @ConfigEntry.Gui.CollapsibleObject
+ public SpawnSettings ptarmiganSettings = new SpawnSettings(5, 2, 5);
- public static class SpawnSettings {
- @ConfigEntry.Gui.RequiresRestart
- public int weight;
- @ConfigEntry.Gui.RequiresRestart
- public int minGroupSize;
- @ConfigEntry.Gui.RequiresRestart
- public int maxGroupSize;
+ public static class SpawnSettings {
+ @ConfigEntry.Gui.RequiresRestart
+ public int weight;
+ @ConfigEntry.Gui.RequiresRestart
+ public int minGroupSize;
+ @ConfigEntry.Gui.RequiresRestart
+ public int maxGroupSize;
- public SpawnSettings(int weight, int minGroupSize, int maxGroupSize) {
- this.weight = weight;
- this.minGroupSize = minGroupSize;
- this.maxGroupSize = maxGroupSize;
- }
- }
- }
+ public SpawnSettings(int weight, int minGroupSize, int maxGroupSize) {
+ this.weight = weight;
+ this.minGroupSize = minGroupSize;
+ this.maxGroupSize = maxGroupSize;
+ }
+ }
+ }
- public static class GenerationOptions {
- @ConfigEntry.Gui.RequiresRestart
- public boolean genDriftwood = true;
- @ConfigEntry.Gui.RequiresRestart
- public boolean genBlueberry = true;
- @ConfigEntry.Gui.RequiresRestart
- public boolean genCloudberry = true;
- @ConfigEntry.Gui.RequiresRestart
- public boolean genRaspberry = true;
- @ConfigEntry.Gui.RequiresRestart
- public boolean genSalmonberry = true;
- @ConfigEntry.Gui.RequiresRestart
- public boolean genLabradorTea = true;
- }
+ public static class GenerationOptions {
+ @ConfigEntry.Gui.RequiresRestart
+ public boolean genDriftwood = true;
+ @ConfigEntry.Gui.RequiresRestart
+ public boolean genBlueberry = true;
+ @ConfigEntry.Gui.RequiresRestart
+ public boolean genCloudberry = true;
+ @ConfigEntry.Gui.RequiresRestart
+ public boolean genRaspberry = true;
+ @ConfigEntry.Gui.RequiresRestart
+ public boolean genSalmonberry = true;
+ @ConfigEntry.Gui.RequiresRestart
+ public boolean genLabradorTea = true;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java
index 423a970c..b2336911 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java
@@ -1,95 +1,102 @@
package com.github.platymemo.alaskanativecraft.entity;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.item.HarpoonItem;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
-import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
-import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
-import net.fabricmc.fabric.mixin.object.builder.SpawnRestrictionAccessor;
-import net.minecraft.entity.*;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityDimensions;
+import net.minecraft.entity.EntityType;
+import net.minecraft.entity.SpawnGroup;
+import net.minecraft.entity.SpawnRestriction;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.Heightmap;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import org.quiltmc.qsl.worldgen.biome.api.BiomeModifications;
+import org.quiltmc.qsl.worldgen.biome.api.BiomeSelectors;
public class AlaskaEntities {
- private static final Map> ENTITY_TYPES = new LinkedHashMap<>();
-
- public static final EntityType HARP_SEAL = add("harp_seal", createEntity(SpawnGroup.WATER_CREATURE, SealEntity::new, true, 1.0F, 0.6F));
- public static final EntityType PTARMIGAN = add("ptarmigan", createEntity(SpawnGroup.AMBIENT, PtarmiganEntity::new, false, 0.5F, 0.5F));
- public static final EntityType MOOSE = add("moose", createEntity(SpawnGroup.CREATURE, MooseEntity::new, true, 3F, 2.6F));
- public static final EntityType DOGSLED = add("dogsled", createEntity(SpawnGroup.MISC, DogsledEntity::new, false, 1.5F, 1.0F));
-
- public static final EntityType WOODEN_HARPOON = add("wooden_harpoon", createHarpoon(AlaskaItems.WOODEN_HARPOON));
- public static final EntityType STONE_HARPOON = add("stone_harpoon", createHarpoon(AlaskaItems.STONE_HARPOON));
- public static final EntityType IRON_HARPOON = add("iron_harpoon", createHarpoon(AlaskaItems.IRON_HARPOON));
- public static final EntityType GOLDEN_HARPOON = add("golden_harpoon", createHarpoon(AlaskaItems.GOLDEN_HARPOON));
- public static final EntityType DIAMOND_HARPOON = add("diamond_harpoon", createHarpoon(AlaskaItems.DIAMOND_HARPOON));
- public static final EntityType NETHERITE_HARPOON = add("netherite_harpoon", createHarpoon(AlaskaItems.NETHERITE_HARPOON));
-
- public static void register() {
- for (Identifier id : ENTITY_TYPES.keySet()) {
- Registry.register(Registry.ENTITY_TYPE, id, ENTITY_TYPES.get(id));
- }
-
- initAttributes();
- initSpawns();
- initSpawnRestrictions();
- }
-
- private static void initSpawnRestrictions() {
- SpawnRestrictionAccessor.callRegister(HARP_SEAL, SpawnRestriction.Location.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SealEntity::canSpawn);
- SpawnRestrictionAccessor.callRegister(MOOSE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn);
- SpawnRestrictionAccessor.callRegister(PTARMIGAN, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, PtarmiganEntity::isValidSpawn);
- }
-
- private static void initAttributes() {
- FabricDefaultAttributeRegistry.register(HARP_SEAL, SealEntity.createSealAttributes());
- FabricDefaultAttributeRegistry.register(PTARMIGAN, PtarmiganEntity.createPtarmiganAttributes());
- FabricDefaultAttributeRegistry.register(MOOSE, MooseEntity.createMooseAttributes());
- }
-
- private static void initSpawns() {
- AlaskaConfig.SpawnOptions spawnOptions = AlaskaConfig.getConfig().spawning;
- BiomeModifications.addSpawn(BiomeSelectors.tag(AlaskaTags.HAS_SEAL),
- SpawnGroup.WATER_CREATURE, HARP_SEAL,
- spawnOptions.sealOceanSettings.weight,
- spawnOptions.sealOceanSettings.minGroupSize,
- spawnOptions.sealOceanSettings.maxGroupSize);
- BiomeModifications.addSpawn(BiomeSelectors.tag(AlaskaTags.HAS_MOOSE),
- SpawnGroup.CREATURE, MOOSE,
- spawnOptions.mooseSettings.weight,
- spawnOptions.mooseSettings.minGroupSize,
- spawnOptions.mooseSettings.maxGroupSize);
- BiomeModifications.addSpawn(BiomeSelectors.tag(AlaskaTags.HAS_PTARMIGAN),
- SpawnGroup.AMBIENT, PTARMIGAN,
- spawnOptions.ptarmiganSettings.weight,
- spawnOptions.ptarmiganSettings.minGroupSize,
- spawnOptions.ptarmiganSettings.maxGroupSize);
- }
-
- private static > E add(String name, E type) {
- Identifier id = new Identifier(AlaskaNativeCraft.MOD_ID, name);
- ENTITY_TYPES.put(id, type);
- return type;
- }
-
- private static EntityType createHarpoon(HarpoonItem item) {
- return FabricEntityTypeBuilder.create(SpawnGroup.MISC, (entity, world) -> new HarpoonEntity(entity, world, item)).dimensions(EntityDimensions.fixed(0.5F, 0.5F)).build();
- }
-
- private static EntityType createEntity(SpawnGroup group, EntityType.EntityFactory factory, boolean changingDimensions, float width, float height) {
- if (changingDimensions) {
- return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.changing(width, height)).build();
- }
- return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.fixed(width, height)).build();
- }
+ private static final Map> ENTITY_TYPES = new LinkedHashMap<>();
+
+ public static final EntityType HARP_SEAL = add("harp_seal", createEntity(SpawnGroup.WATER_CREATURE, SealEntity::new, true, 1.0F, 0.6F));
+ public static final EntityType PTARMIGAN = add("ptarmigan", createEntity(SpawnGroup.AMBIENT, PtarmiganEntity::new, false, 0.5F, 0.5F));
+ public static final EntityType MOOSE = add("moose", createEntity(SpawnGroup.CREATURE, MooseEntity::new, true, 3F, 2.6F));
+ public static final EntityType DOGSLED = add("dogsled", createEntity(SpawnGroup.MISC, DogsledEntity::new, false, 1.5F, 1.0F));
+
+ public static final EntityType WOODEN_HARPOON = add("wooden_harpoon", createHarpoon(AlaskaItems.WOODEN_HARPOON));
+ public static final EntityType STONE_HARPOON = add("stone_harpoon", createHarpoon(AlaskaItems.STONE_HARPOON));
+ public static final EntityType IRON_HARPOON = add("iron_harpoon", createHarpoon(AlaskaItems.IRON_HARPOON));
+ public static final EntityType GOLDEN_HARPOON = add("golden_harpoon", createHarpoon(AlaskaItems.GOLDEN_HARPOON));
+ public static final EntityType DIAMOND_HARPOON = add("diamond_harpoon", createHarpoon(AlaskaItems.DIAMOND_HARPOON));
+ public static final EntityType NETHERITE_HARPOON = add("netherite_harpoon", createHarpoon(AlaskaItems.NETHERITE_HARPOON));
+
+ public static void register() {
+ for (Identifier id : ENTITY_TYPES.keySet()) {
+ Registry.register(Registry.ENTITY_TYPE, id, ENTITY_TYPES.get(id));
+ }
+
+ initAttributes();
+ initSpawns();
+ initSpawnRestrictions();
+ }
+
+ private static void initSpawnRestrictions() {
+ SpawnRestriction.register(HARP_SEAL, SpawnRestriction.Location.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SealEntity::canSpawn);
+ SpawnRestriction.register(MOOSE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn);
+ SpawnRestriction.register(PTARMIGAN, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, PtarmiganEntity::isValidSpawn);
+ }
+
+ // IntelliJ wrongly infers that the register call fails due to calling an accessor that throws an AssertionError
+ @SuppressWarnings("ConstantConditions")
+ private static void initAttributes() {
+ FabricDefaultAttributeRegistry.register(HARP_SEAL, SealEntity.createSealAttributes());
+ FabricDefaultAttributeRegistry.register(PTARMIGAN, PtarmiganEntity.createPtarmiganAttributes());
+ FabricDefaultAttributeRegistry.register(MOOSE, MooseEntity.createMooseAttributes());
+ }
+
+ private static void initSpawns() {
+ AlaskaConfig.SpawnOptions spawnOptions = AlaskaConfig.getConfig().spawning;
+ BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_SEAL),
+ SpawnGroup.WATER_CREATURE, HARP_SEAL,
+ spawnOptions.sealOceanSettings.weight,
+ spawnOptions.sealOceanSettings.minGroupSize,
+ spawnOptions.sealOceanSettings.maxGroupSize);
+ BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_MOOSE),
+ SpawnGroup.CREATURE, MOOSE,
+ spawnOptions.mooseSettings.weight,
+ spawnOptions.mooseSettings.minGroupSize,
+ spawnOptions.mooseSettings.maxGroupSize);
+ BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_PTARMIGAN),
+ SpawnGroup.AMBIENT, PTARMIGAN,
+ spawnOptions.ptarmiganSettings.weight,
+ spawnOptions.ptarmiganSettings.minGroupSize,
+ spawnOptions.ptarmiganSettings.maxGroupSize);
+ }
+
+ private static > E add(String name, E type) {
+ Identifier id = new Identifier(AlaskaNativeCraft.MOD_ID, name);
+ ENTITY_TYPES.put(id, type);
+ return type;
+ }
+
+ private static EntityType createHarpoon(HarpoonItem item) {
+ return FabricEntityTypeBuilder.create(SpawnGroup.MISC, (entity, world) -> new HarpoonEntity(entity, world, item)).dimensions(EntityDimensions.fixed(0.5F, 0.5F)).build();
+ }
+
+ private static EntityType createEntity(SpawnGroup group, EntityType.EntityFactory factory, boolean changingDimensions, float width, float height) {
+ if (changingDimensions) {
+ return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.changing(width, height)).build();
+ }
+ return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.fixed(width, height)).build();
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java
index 9491fa13..6ea3e293 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java
@@ -1,15 +1,27 @@
package com.github.platymemo.alaskanativecraft.entity;
+import java.util.Iterator;
+import java.util.List;
+
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LilyPadBlock;
-import net.minecraft.entity.*;
+import net.minecraft.entity.Dismounting;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityDimensions;
+import net.minecraft.entity.EntityPose;
+import net.minecraft.entity.EntityType;
+import net.minecraft.entity.LivingEntity;
+import net.minecraft.entity.MovementType;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
@@ -46,849 +58,845 @@
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.function.BooleanBiFunction;
-import net.minecraft.util.math.*;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Box;
+import net.minecraft.util.math.Direction;
+import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockLocating;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Iterator;
-import java.util.List;
public class DogsledEntity extends Entity implements Inventory, NamedScreenHandlerFactory {
- private static final TrackedData DAMAGE_WOBBLE_TICKS;
- private static final TrackedData DAMAGE_WOBBLE_SIDE;
- private static final TrackedData DAMAGE_WOBBLE_STRENGTH;
- private static final TrackedData DOGSLED_TYPE;
-
- static {
- DAMAGE_WOBBLE_TICKS = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER);
- DAMAGE_WOBBLE_SIDE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER);
- DAMAGE_WOBBLE_STRENGTH = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.FLOAT);
- DOGSLED_TYPE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER);
- }
-
- private float ticksUnderwater;
- private float yawVelocity;
- private float velocityDecay;
- private int clientInterpolationSteps;
- private double x;
- private double y;
- private double z;
- private double dogsledYaw;
- private double dogsledPitch;
- private boolean pressingLeft;
- private boolean pressingRight;
- private boolean pressingForward;
- private boolean pressingBack;
- private double waterLevel;
- private Location location;
- private DefaultedList inventory;
- @Nullable
- private Identifier lootTableId;
- private long lootSeed;
-
- public DogsledEntity(EntityType> entityType, World world) {
- super(entityType, world);
- this.stepHeight = 1.0F;
- this.inventory = DefaultedList.ofSize(36, ItemStack.EMPTY);
- this.onGround = true;
- }
-
- public DogsledEntity(World world, double x, double y, double z) {
- this(AlaskaEntities.DOGSLED, world);
- this.setPosition(x, y, z);
- this.updateTrackedPosition(x, y, z);
- this.setVelocity(Vec3d.ZERO);
- this.prevX = x;
- this.prevY = y;
- this.prevZ = z;
- }
-
- public static boolean method_30959(Entity entity, @NotNull Entity entity2) {
- return (entity2.isCollidable() || entity2.isPushable()) && !entity.isConnectedThroughVehicle(entity2);
- }
-
- @Override
- protected float getEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) {
- return dimensions.height;
- }
-
- @Override
- protected void initDataTracker() {
- this.dataTracker.startTracking(DAMAGE_WOBBLE_TICKS, 0);
- this.dataTracker.startTracking(DAMAGE_WOBBLE_SIDE, 1);
- this.dataTracker.startTracking(DAMAGE_WOBBLE_STRENGTH, 0.0F);
- this.dataTracker.startTracking(DOGSLED_TYPE, DogsledEntity.Type.OAK.ordinal());
- }
-
- @Override
- public boolean collidesWith(Entity other) {
- return method_30959(this, other);
- }
-
- @Override
- public boolean isCollidable() {
- return true;
- }
-
- @Override
- public boolean isPushable() {
- return true;
- }
-
- @Override
- protected Vec3d positionInPortal(Direction.Axis axis, BlockLocating.Rectangle arg) {
- return LivingEntity.positionInPortal(super.positionInPortal(axis, arg));
- }
-
- @Override
- public void pushAwayFrom(Entity entity) {
- if (entity instanceof BoatEntity || entity instanceof DogsledEntity) {
- if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
- super.pushAwayFrom(entity);
- }
- } else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) {
- super.pushAwayFrom(entity);
- }
-
- }
-
- public Item asItem() {
- return switch (this.getDogsledType()) {
- default -> AlaskaItems.OAK_DOGSLED;
- case SPRUCE -> AlaskaItems.SPRUCE_DOGSLED;
- case BIRCH -> AlaskaItems.BIRCH_DOGSLED;
- case JUNGLE -> AlaskaItems.JUNGLE_DOGSLED;
- case ACACIA -> AlaskaItems.ACACIA_DOGSLED;
- case DARK_OAK -> AlaskaItems.DARK_OAK_DOGSLED;
- };
- }
-
- @Override
- @Environment(EnvType.CLIENT)
- public void animateDamage() {
- this.setDamageWobbleSide(-this.getDamageWobbleSide());
- this.setDamageWobbleTicks(10);
- this.setDamageWobbleStrength(this.getDamageWobbleStrength() * 11.0F);
- }
-
- @Override
- public boolean collides() {
- return !this.isRemoved();
- }
-
- @Override
- @Environment(EnvType.CLIENT)
- public void updateTrackedPositionAndAngles(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.dogsledYaw = yaw;
- this.dogsledPitch = pitch;
- this.clientInterpolationSteps = 10;
- }
-
- @Override
- public Direction getMovementDirection() {
- return this.getHorizontalFacing().rotateYClockwise();
- }
-
- @Override
- public void tick() {
- this.location = this.checkLocation();
- if (this.location != Location.UNDER_WATER && this.location != Location.UNDER_FLOWING_WATER) {
- this.ticksUnderwater = 0.0F;
- } else {
- ++this.ticksUnderwater;
- }
-
- if (!this.world.isClient && this.ticksUnderwater >= 60.0F) {
- this.removeAllPassengers();
- }
-
- if (this.getDamageWobbleTicks() > 0) {
- this.setDamageWobbleTicks(this.getDamageWobbleTicks() - 1);
- }
-
- if (this.getDamageWobbleStrength() > 0.0F) {
- this.setDamageWobbleStrength(this.getDamageWobbleStrength() - 1.0F);
- }
-
- super.tick();
- this.clientInterpolation();
- if (this.isLogicalSideForUpdatingMovement()) {
- this.updateVelocity();
- if (this.world.isClient) {
- this.updateMovement();
- }
- this.move(MovementType.SELF, this.getVelocity());
- } else {
- this.setVelocity(Vec3d.ZERO);
- }
-
- for (Entity passenger : this.getPassengerList()) {
- if (passenger instanceof WolfEntity) {
- if (!MathHelper.approximatelyEquals(this.getVelocity().length(), 0.0D)) {
- ((TameableEntity) passenger).setInSittingPose(false);
- }
- ((LivingEntity) passenger).updateLimbs(((LivingEntity) passenger), false);
- }
- }
-
- this.checkBlockCollision();
- List list = this.world.getOtherEntities(this, this.getBoundingBox().expand(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntityPredicates.canBePushedBy(this));
- if (!list.isEmpty()) {
- boolean bl = !this.world.isClient;
-
- for (Entity entity : list) {
- if (!entity.hasPassenger(this)) {
- if (bl && this.getPassengerList().size() < 2 && !entity.hasVehicle() && entity instanceof WolfEntity && ((WolfEntity) entity).getOwner() != null && !((WolfEntity) entity).isBaby()) {
- entity.startRiding(this);
- } else {
- this.pushAwayFrom(entity);
- }
- }
- }
- }
-
- }
-
- private void clientInterpolation() {
- if (this.isLogicalSideForUpdatingMovement()) {
- this.clientInterpolationSteps = 0;
- this.updateTrackedPosition(this.getX(), this.getY(), this.getZ());
- }
-
- if (this.clientInterpolationSteps > 0) {
- double d = this.getX() + (this.x - this.getX()) / (double) this.clientInterpolationSteps;
- double e = this.getY() + (this.y - this.getY()) / (double) this.clientInterpolationSteps;
- double f = this.getZ() + (this.z - this.getZ()) / (double) this.clientInterpolationSteps;
- double g = MathHelper.wrapDegrees(this.dogsledYaw - (double) this.getYaw());
- float yaw = (float) ((double) this.getYaw() + g / (double) this.clientInterpolationSteps);
- float pitch = (float) ((double) this.getPitch() + (this.dogsledPitch - (double) this.getPitch()) / (double) this.clientInterpolationSteps);
- --this.clientInterpolationSteps;
- this.setPosition(d, e, f);
- this.setRotation(yaw, pitch);
- }
- }
-
- private Location checkLocation() {
- Location location = this.getUnderWaterLocation();
- if (location != null) {
- this.waterLevel = this.getBoundingBox().maxY;
- return location;
- } else {
- float f = this.getBlockSlipperiness();
- if (f > 0.0F) {
- return Location.ON_LAND;
- } else {
- return Location.IN_AIR;
- }
- }
- }
-
- public float getBlockSlipperiness() {
- Box box = this.getBoundingBox();
- Box box2 = new Box(box.minX, box.minY - 0.001D, box.minZ, box.maxX, box.minY, box.maxZ);
- int i = MathHelper.floor(box2.minX) - 1;
- int j = MathHelper.ceil(box2.maxX) + 1;
- int k = MathHelper.floor(box2.minY) - 1;
- int l = MathHelper.ceil(box2.maxY) + 1;
- int m = MathHelper.floor(box2.minZ) - 1;
- int n = MathHelper.ceil(box2.maxZ) + 1;
- VoxelShape voxelShape = VoxelShapes.cuboid(box2);
- float f = 0.0F;
- int o = 0;
- BlockPos.Mutable mutable = new BlockPos.Mutable();
-
- for (int p = i; p < j; ++p) {
- for (int q = m; q < n; ++q) {
- int r = (p != i && p != j - 1 ? 0 : 1) + (q != m && q != n - 1 ? 0 : 1);
- if (r != 2) {
- for (int s = k; s < l; ++s) {
- if (r <= 0 || s != k && s != l - 1) {
- mutable.set(p, s, q);
- BlockState blockState = this.world.getBlockState(mutable);
- BlockState topBlock = this.world.getBlockState(mutable.up());
- if (blockState.isOf(Blocks.SNOW_BLOCK) || topBlock.isOf(Blocks.SNOW)) {
- f += 0.95F;
- ++o;
- } else if (!(blockState.getBlock() instanceof LilyPadBlock) && VoxelShapes.matchesAnywhere(blockState.getCollisionShape(this.world, mutable).offset(p, s, q), voxelShape, BooleanBiFunction.AND)) {
- f += blockState.getBlock().getSlipperiness();
- ++o;
- }
- }
- }
- }
- }
- }
-
- return f / (float) o;
- }
-
- @Nullable
- private Location getUnderWaterLocation() {
- Box box = this.getBoundingBox();
- double d = box.maxY + 0.001D;
- int i = MathHelper.floor(box.minX);
- int j = MathHelper.ceil(box.maxX);
- int k = MathHelper.floor(box.maxY);
- int l = MathHelper.ceil(d);
- int m = MathHelper.floor(box.minZ);
- int n = MathHelper.ceil(box.maxZ);
- boolean bl = false;
- BlockPos.Mutable mutable = new BlockPos.Mutable();
-
- for (int o = i; o < j; ++o) {
- for (int p = k; p < l; ++p) {
- for (int q = m; q < n; ++q) {
- mutable.set(o, p, q);
- FluidState fluidState = this.world.getFluidState(mutable);
- if (fluidState.isIn(FluidTags.WATER)) {
- float f = (float) p + fluidState.getHeight(this.world, mutable);
- this.waterLevel = Math.max(f, this.waterLevel);
- bl |= box.minY < (double) f;
- if (d < (double) ((float) mutable.getY() + fluidState.getHeight(this.world, mutable))) {
- if (!fluidState.isStill()) {
- return Location.UNDER_FLOWING_WATER;
- }
-
- bl = true;
- }
- }
- }
- }
- }
-
- return bl ? Location.UNDER_WATER : null;
- }
-
- private void updateMovement() {
- if (this.hasPassengers()) {
- float f = 0.0F;
- if (this.pressingLeft) {
- --this.yawVelocity;
- }
-
- if (this.pressingRight) {
- ++this.yawVelocity;
- }
-
- if (this.pressingRight != this.pressingLeft && !this.pressingForward && !this.pressingBack) {
- f += 0.005F;
- }
-
- this.setYaw(this.getYaw() + this.yawVelocity);
- if (this.pressingForward) {
- f += 0.04F;
- }
-
- if (this.pressingBack) {
- f -= 0.005F;
- }
-
- this.setVelocity(this.getVelocity().add((MathHelper.sin(-this.getYaw() * 0.017453292F) * f), 0.0D, (MathHelper.cos(this.getYaw() * 0.017453292F) * f)));
- }
- }
-
- private void updateVelocity() {
- double e = this.hasNoGravity() ? 0.0D : -0.03999999910593033D;
- double f = 0.0D;
- if (this.location == Location.ON_LAND) {
- velocityDecay = this.getBlockSlipperiness();
- } else {
- if (this.location == Location.UNDER_FLOWING_WATER) {
- e = -7.0E-4D;
- } else if (this.location == Location.UNDER_WATER) {
- f = 0.009999999776482582D;
- }
- velocityDecay *= 0.95F;
- }
-
- if (this.getPassengerList().size() < 2) {
- velocityDecay /= 1.15F;
- }
-
- Vec3d vec3d = this.getVelocity();
- this.setVelocity(vec3d.x * (double) velocityDecay, vec3d.y + e, vec3d.z * (double) velocityDecay);
- this.yawVelocity *= velocityDecay / 1.5F;
- if (f > 0.0D) {
- Vec3d vec3d2 = this.getVelocity();
- this.setVelocity(vec3d2.x, (vec3d2.y + f * 0.06153846016296973D) * 0.75D, vec3d2.z);
- }
- }
-
- @Override
- public Vec3d updatePassengerForDismount(@NotNull LivingEntity passenger) {
- Vec3d vec3d = getPassengerDismountOffset((this.getWidth() * MathHelper.SQUARE_ROOT_OF_TWO), passenger.getWidth(), passenger.getYaw());
- double d = this.getX() + vec3d.x;
- double e = this.getZ() + vec3d.z;
- BlockPos blockPos = new BlockPos(d, this.getBoundingBox().maxY, e);
- BlockPos blockPos2 = blockPos.down();
- if (!this.world.isWater(blockPos2)) {
- List list = Lists.newArrayList();
- double f = this.world.getDismountHeight(blockPos);
- if (Dismounting.canDismountInBlock(f)) {
- list.add(new Vec3d(d, (double) blockPos.getY() + f, e));
- }
-
- double g = this.world.getDismountHeight(blockPos2);
- if (Dismounting.canDismountInBlock(g)) {
- list.add(new Vec3d(d, (double) blockPos2.getY() + g, e));
- }
-
- for (EntityPose entityPose : passenger.getPoses()) {
- for (Vec3d vec3d2 : list) {
- if (Dismounting.canPlaceEntityAt(this.world, vec3d2, passenger, entityPose)) {
- passenger.setPose(entityPose);
- return vec3d2;
- }
- }
- }
- }
-
- return super.updatePassengerForDismount(passenger);
- }
-
- protected void copyEntityData(@NotNull Entity entity) {
- entity.setBodyYaw(this.getYaw());
- float f = MathHelper.wrapDegrees(entity.getYaw() - this.getYaw());
- float g = MathHelper.clamp(f, -105.0F, 105.0F);
- entity.prevYaw += (g - f);
- entity.setYaw(entity.getYaw() + g - f);
- entity.setHeadYaw(entity.getYaw());
- }
-
- @Override
- @Environment(EnvType.CLIENT)
- public void onPassengerLookAround(Entity passenger) {
- this.copyEntityData(passenger);
- }
-
- @Override
- protected void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) {
- if (!this.hasVehicle()) {
- if (onGround) {
- if (this.fallDistance > 3.0F) {
- if (this.location != Location.ON_LAND) {
- this.fallDistance = 0.0F;
- return;
- }
-
- this.handleFallDamage(this.fallDistance, 1.0F, DamageSource.FALL);
- if (!this.world.isClient && !this.isRemoved()) {
- this.kill();
- if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
- int j;
- for (j = 0; j < 3; ++j) {
- this.dropItem(this.getDogsledType().getBaseBlock());
- }
-
- for (j = 0; j < 2; ++j) {
- this.dropItem(Items.STICK);
- }
-
- dropItems(null);
- }
- }
- }
-
- this.fallDistance = 0.0F;
- } else if (!this.world.getFluidState(this.getBlockPos().down()).isIn(FluidTags.WATER) && heightDifference < 0.0D) {
- this.fallDistance = (float) ((double) this.fallDistance - heightDifference);
- }
-
- }
- }
-
- public float getDamageWobbleStrength() {
- return this.dataTracker.get(DAMAGE_WOBBLE_STRENGTH);
- }
-
- public void setDamageWobbleStrength(float wobbleStrength) {
- this.dataTracker.set(DAMAGE_WOBBLE_STRENGTH, wobbleStrength);
- }
-
- public int getDamageWobbleTicks() {
- return this.dataTracker.get(DAMAGE_WOBBLE_TICKS);
- }
-
- public void setDamageWobbleTicks(int wobbleTicks) {
- this.dataTracker.set(DAMAGE_WOBBLE_TICKS, wobbleTicks);
- }
-
- public int getDamageWobbleSide() {
- return this.dataTracker.get(DAMAGE_WOBBLE_SIDE);
- }
-
- public void setDamageWobbleSide(int side) {
- this.dataTracker.set(DAMAGE_WOBBLE_SIDE, side);
- }
-
- public DogsledEntity.Type getDogsledType() {
- return DogsledEntity.Type.getType(this.dataTracker.get(DOGSLED_TYPE));
- }
-
- public void setDogsledType(@NotNull DogsledEntity.Type type) {
- this.dataTracker.set(DOGSLED_TYPE, type.ordinal());
- }
-
- @Override
- protected boolean canAddPassenger(Entity passenger) {
- int i = this.getPassengerList().size();
- if (this.isSubmergedIn(FluidTags.WATER)) {
- return false;
- }
- if (i == 0) {
- return passenger instanceof PlayerEntity || passenger instanceof WolfEntity;
- } else if (i == 1) {
- return passenger instanceof PlayerEntity;
- }
- return false;
- }
-
- @Override
- @Nullable
- public Entity getPrimaryPassenger() {
- List list = this.getPassengerList();
- return list.isEmpty() ? null : list.get(0);
- }
-
- @Override
- public boolean isSubmergedInWater() {
- return this.location == Location.UNDER_WATER || this.location == Location.UNDER_FLOWING_WATER;
- }
-
- @Override
- public Packet> createSpawnPacket() {
- return new EntitySpawnS2CPacket(this);
- }
-
- @Environment(EnvType.CLIENT)
- public void setInputs(boolean pressingLeft, boolean pressingRight, boolean pressingForward, boolean pressingBack) {
- this.pressingLeft = pressingLeft;
- this.pressingRight = pressingRight;
- this.pressingForward = pressingForward;
- this.pressingBack = pressingBack;
- }
-
- @Override
- public int size() {
- return 27;
- }
-
- @Override
- public double getMountedHeightOffset() {
- return 0.2D;
- }
-
- @Override
- public boolean damage(DamageSource source, float amount) {
- if (!this.world.isClient && !this.isRemoved()) {
- if (this.isInvulnerableTo(source)) {
- return false;
- } else {
- this.setDamageWobbleSide(-this.getDamageWobbleSide());
- this.setDamageWobbleTicks(10);
- this.scheduleVelocityUpdate();
- this.setDamageWobbleStrength(this.getDamageWobbleStrength() + amount * 10.0F);
- boolean bl = source.getAttacker() instanceof PlayerEntity && ((PlayerEntity) source.getAttacker()).getAbilities().creativeMode;
- if (bl || this.getDamageWobbleStrength() > 40.0F) {
- this.removeAllPassengers();
- if (bl && !this.hasCustomName()) {
- this.discard();
- } else {
- this.dropItems(source);
- }
- }
-
- return true;
- }
- } else {
- return true;
- }
- }
-
- @Override
- public void removeAllPassengers() {
- for (int i = this.getPassengerList().size() - 1; i >= 0; --i) {
- Entity entity = this.getPassengerList().get(i);
- if (entity instanceof WolfEntity) {
- entity.noClip = false;
- }
- entity.stopRiding();
- }
- }
-
- public void dropItems(DamageSource damageSource) {
- this.remove(RemovalReason.KILLED);
- if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
- if (damageSource != null) {
- ItemStack itemStack = this.asItem().getDefaultStack();
- if (this.hasCustomName()) {
- itemStack.setCustomName(this.getCustomName());
- }
- this.dropStack(itemStack);
- }
- ItemScatterer.spawn(this.world, this, this);
- if (damageSource != null && !this.world.isClient) {
- Entity entity = damageSource.getSource();
- if (entity != null && entity.getType() == EntityType.PLAYER) {
- PiglinBrain.onGuardedBlockInteracted((PlayerEntity) entity, true);
- }
- }
- }
- }
-
- @Override
- public void updatePassengerPosition(Entity passenger) {
- this.updatePassengerPosition(passenger, Entity::setPosition);
- }
-
- private void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) {
- if (this.hasPassenger(passenger)) {
- if (passenger instanceof PlayerEntity) {
- float g = (float) ((this.isRemoved() ? 0.009999999776482582D : this.getMountedHeightOffset()) + passenger.getHeightOffset());
- double x = MathHelper.cos((this.getYaw() + 90.0F) * 0.0174533F);
- double z = MathHelper.sin((this.getYaw() + 90.0F) * 0.0174533F);
- positionUpdater.accept(passenger, this.getX() - x, this.getY() + (double) g, this.getZ() - z);
- } else if (passenger instanceof WolfEntity) {
- passenger.noClip = true;
- Vec3d vec3d = (new Vec3d(1.5D, 0.0D, 0.0D)).rotateY(-this.getYaw() * 0.017453292F - 1.5707964F);
- positionUpdater.accept(passenger, this.getX() + vec3d.x, this.getY(), this.getZ() + vec3d.z);
- passenger.setYaw(passenger.getYaw() + this.yawVelocity);
- passenger.setHeadYaw(passenger.getHeadYaw() + this.yawVelocity);
- this.copyEntityData(passenger);
- }
- }
- }
-
- @Override
- public void writeCustomDataToNbt(@NotNull NbtCompound tag) {
- tag.putString("Type", this.getDogsledType().getName());
- if (this.lootTableId != null) {
- tag.putString("LootTable", this.lootTableId.toString());
- if (this.lootSeed != 0L) {
- tag.putLong("LootTableSeed", this.lootSeed);
- }
- } else {
- Inventories.writeNbt(tag, this.inventory);
- }
-
- }
-
- @Override
- public void readCustomDataFromNbt(@NotNull NbtCompound tag) {
- if (tag.contains("Type", 8)) {
- this.setDogsledType(DogsledEntity.Type.getType(tag.getString("Type")));
- }
- this.inventory = DefaultedList.ofSize(this.size(), ItemStack.EMPTY);
- if (tag.contains("LootTable", 8)) {
- this.lootTableId = new Identifier(tag.getString("LootTable"));
- this.lootSeed = tag.getLong("LootTableSeed");
- } else {
- Inventories.readNbt(tag, this.inventory);
- }
-
- }
-
- @Override
- public ActionResult interact(@NotNull PlayerEntity player, Hand hand) {
- if (player.isSneaking()) {
- player.openHandledScreen(this);
- if (!player.world.isClient) {
- PiglinBrain.onGuardedBlockInteracted(player, true);
- return ActionResult.CONSUME;
- } else {
- return ActionResult.SUCCESS;
- }
- } else {
- if (this.ticksUnderwater < 60.0F) {
- if (!this.world.isClient) {
- return player.startRiding(this) ? ActionResult.CONSUME : ActionResult.PASS;
- } else {
- return ActionResult.SUCCESS;
- }
- } else {
- return ActionResult.PASS;
- }
- }
- }
-
- @Override
- public boolean isEmpty() {
- Iterator var1 = this.inventory.iterator();
-
- ItemStack itemStack;
- do {
- if (!var1.hasNext()) {
- return true;
- }
-
- itemStack = var1.next();
- } while (itemStack.isEmpty());
-
- return false;
- }
-
- @Override
- public ItemStack getStack(int slot) {
- this.generateLoot(null);
- return this.inventory.get(slot);
- }
-
- @Override
- public ItemStack removeStack(int slot, int amount) {
- this.generateLoot(null);
- return Inventories.splitStack(this.inventory, slot, amount);
- }
-
- @Override
- public ItemStack removeStack(int slot) {
- this.generateLoot(null);
- ItemStack itemStack = this.inventory.get(slot);
- if (itemStack.isEmpty()) {
- return ItemStack.EMPTY;
- } else {
- this.inventory.set(slot, ItemStack.EMPTY);
- return itemStack;
- }
- }
-
- @Override
- public void setStack(int slot, ItemStack stack) {
- this.generateLoot(null);
- this.inventory.set(slot, stack);
- if (!stack.isEmpty() && stack.getCount() > this.getMaxCountPerStack()) {
- stack.setCount(this.getMaxCountPerStack());
- }
-
- }
-
- public boolean equip(int slot, ItemStack item) {
- if (slot >= 0 && slot < this.size()) {
- this.setStack(slot, item);
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public void markDirty() {
- }
-
- @Override
- public boolean canPlayerUse(PlayerEntity player) {
- if (this.isRemoved()) {
- return false;
- } else {
- return player.squaredDistanceTo(this) <= 64.0D;
- }
- }
-
- public void generateLoot(@Nullable PlayerEntity player) {
- if (this.lootTableId != null && this.world.getServer() != null) {
- LootTable lootTable = this.world.getServer().getLootManager().getTable(this.lootTableId);
- if (player instanceof ServerPlayerEntity) {
- Criteria.PLAYER_GENERATES_CONTAINER_LOOT.trigger((ServerPlayerEntity) player, this.lootTableId);
- }
-
- this.lootTableId = null;
- LootContext.Builder builder = (new LootContext.Builder((ServerWorld) this.world)).parameter(LootContextParameters.ORIGIN, this.getPos()).random(this.lootSeed);
- if (player != null) {
- builder.luck(player.getLuck()).parameter(LootContextParameters.THIS_ENTITY, player);
- }
-
- lootTable.supplyInventory(this, builder.build(LootContextTypes.CHEST));
- }
-
- }
-
- @Override
- public void clear() {
- this.generateLoot(null);
- this.inventory.clear();
- }
-
- public void setLootTable(Identifier id, long lootSeed) {
- this.lootTableId = id;
- this.lootSeed = lootSeed;
- }
-
- @Override
- @Nullable
- public ScreenHandler createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) {
- if (this.lootTableId != null && playerEntity.isSpectator()) {
- return null;
- } else {
- this.generateLoot(playerInventory.player);
- return this.getScreenHandler(i, playerInventory);
- }
- }
-
- public ScreenHandler getScreenHandler(int syncId, PlayerInventory playerInventory) {
- return GenericContainerScreenHandler.createGeneric9x3(syncId, playerInventory, this);
- }
-
- public enum Type {
- OAK(Blocks.OAK_PLANKS, "oak"),
- SPRUCE(Blocks.SPRUCE_PLANKS, "spruce"),
- BIRCH(Blocks.BIRCH_PLANKS, "birch"),
- JUNGLE(Blocks.JUNGLE_PLANKS, "jungle"),
- ACACIA(Blocks.ACACIA_PLANKS, "acacia"),
- DARK_OAK(Blocks.DARK_OAK_PLANKS, "dark_oak");
-
- private final String name;
- private final Block baseBlock;
-
- Type(Block baseBlock, String name) {
- this.name = name;
- this.baseBlock = baseBlock;
- }
-
- public static DogsledEntity.Type getType(int i) {
- DogsledEntity.Type[] types = values();
- if (i < 0 || i >= types.length) {
- i = 0;
- }
-
- return types[i];
- }
-
- public static DogsledEntity.Type getType(String string) {
- DogsledEntity.Type[] types = values();
-
- for (Type type : types) {
- if (type.getName().equals(string)) {
- return type;
- }
- }
-
- return types[0];
- }
-
- public String getName() {
- return this.name;
- }
-
- public Block getBaseBlock() {
- return this.baseBlock;
- }
-
- public String toString() {
- return this.name;
- }
- }
-
- public enum Location {
- UNDER_WATER,
- UNDER_FLOWING_WATER,
- ON_LAND,
- IN_AIR
- }
+ private static final TrackedData DAMAGE_WOBBLE_TICKS;
+ private static final TrackedData DAMAGE_WOBBLE_SIDE;
+ private static final TrackedData DAMAGE_WOBBLE_STRENGTH;
+ private static final TrackedData DOGSLED_TYPE;
+
+ static {
+ DAMAGE_WOBBLE_TICKS = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER);
+ DAMAGE_WOBBLE_SIDE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER);
+ DAMAGE_WOBBLE_STRENGTH = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.FLOAT);
+ DOGSLED_TYPE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER);
+ }
+
+ private float ticksUnderwater;
+ private float yawVelocity;
+ private float velocityDecay;
+ private int clientInterpolationSteps;
+ private double x;
+ private double y;
+ private double z;
+ private double dogsledYaw;
+ private double dogsledPitch;
+ private boolean pressingLeft;
+ private boolean pressingRight;
+ private boolean pressingForward;
+ private boolean pressingBack;
+ private double waterLevel;
+ private Location location;
+ private DefaultedList inventory;
+ @Nullable
+ private Identifier lootTableId;
+ private long lootSeed;
+
+ public DogsledEntity(EntityType> entityType, World world) {
+ super(entityType, world);
+ this.stepHeight = 1.0F;
+ this.inventory = DefaultedList.ofSize(36, ItemStack.EMPTY);
+ this.onGround = true;
+ }
+
+ public DogsledEntity(World world, double x, double y, double z) {
+ this(AlaskaEntities.DOGSLED, world);
+ this.setPosition(x, y, z);
+ this.setVelocity(Vec3d.ZERO);
+ this.prevX = x;
+ this.prevY = y;
+ this.prevZ = z;
+ }
+
+ @Override
+ protected float getEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) {
+ return dimensions.height;
+ }
+
+ @Override
+ protected void initDataTracker() {
+ this.dataTracker.startTracking(DAMAGE_WOBBLE_TICKS, 0);
+ this.dataTracker.startTracking(DAMAGE_WOBBLE_SIDE, 1);
+ this.dataTracker.startTracking(DAMAGE_WOBBLE_STRENGTH, 0.0F);
+ this.dataTracker.startTracking(DOGSLED_TYPE, DogsledEntity.Type.OAK.ordinal());
+ }
+
+ @Override
+ public boolean collidesWith(Entity other) {
+ return BoatEntity.canCollide(this, other);
+ }
+
+ @Override
+ public boolean isCollidable() {
+ return true;
+ }
+
+ @Override
+ public boolean isPushable() {
+ return true;
+ }
+
+ @Override
+ protected Vec3d positionInPortal(Direction.Axis axis, BlockLocating.Rectangle arg) {
+ return LivingEntity.positionInPortal(super.positionInPortal(axis, arg));
+ }
+
+ @Override
+ public void pushAwayFrom(Entity entity) {
+ if (entity instanceof BoatEntity || entity instanceof DogsledEntity) {
+ if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
+ super.pushAwayFrom(entity);
+ }
+ } else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) {
+ super.pushAwayFrom(entity);
+ }
+ }
+
+ public Item asItem() {
+ return switch (this.getDogsledType()) {
+ case SPRUCE -> AlaskaItems.SPRUCE_DOGSLED;
+ case BIRCH -> AlaskaItems.BIRCH_DOGSLED;
+ case JUNGLE -> AlaskaItems.JUNGLE_DOGSLED;
+ case ACACIA -> AlaskaItems.ACACIA_DOGSLED;
+ case DARK_OAK -> AlaskaItems.DARK_OAK_DOGSLED;
+ default -> AlaskaItems.OAK_DOGSLED;
+ };
+ }
+
+ @Override
+ @Environment(EnvType.CLIENT)
+ public void animateDamage() {
+ this.setDamageWobbleSide(-this.getDamageWobbleSide());
+ this.setDamageWobbleTicks(10);
+ this.setDamageWobbleStrength(this.getDamageWobbleStrength() * 11.0F);
+ }
+
+ @Override
+ public boolean collides() {
+ return !this.isRemoved();
+ }
+
+ @Override
+ @Environment(EnvType.CLIENT)
+ public void updateTrackedPositionAndAngles(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.dogsledYaw = yaw;
+ this.dogsledPitch = pitch;
+ this.clientInterpolationSteps = 10;
+ }
+
+ @Override
+ public Direction getMovementDirection() {
+ return this.getHorizontalFacing().rotateYClockwise();
+ }
+
+ @Override
+ public void tick() {
+ this.location = this.checkLocation();
+ if (this.location != Location.UNDER_WATER && this.location != Location.UNDER_FLOWING_WATER) {
+ this.ticksUnderwater = 0.0F;
+ } else {
+ ++this.ticksUnderwater;
+ }
+
+ if (!this.world.isClient && this.ticksUnderwater >= 60.0F) {
+ this.removeAllPassengers();
+ }
+
+ if (this.getDamageWobbleTicks() > 0) {
+ this.setDamageWobbleTicks(this.getDamageWobbleTicks() - 1);
+ }
+
+ if (this.getDamageWobbleStrength() > 0.0F) {
+ this.setDamageWobbleStrength(this.getDamageWobbleStrength() - 1.0F);
+ }
+
+ super.tick();
+ this.clientInterpolation();
+ if (this.isLogicalSideForUpdatingMovement()) {
+ this.updateVelocity();
+ if (this.world.isClient) {
+ this.updateMovement();
+ }
+
+ this.move(MovementType.SELF, this.getVelocity());
+ } else {
+ this.setVelocity(Vec3d.ZERO);
+ }
+
+ for (Entity passenger : this.getPassengerList()) {
+ if (passenger instanceof WolfEntity) {
+ if (!MathHelper.approximatelyEquals(this.getVelocity().length(), 0.0D)) {
+ ((TameableEntity) passenger).setInSittingPose(false);
+ }
+
+ ((LivingEntity) passenger).updateLimbs(((LivingEntity) passenger), false);
+ }
+ }
+
+ this.checkBlockCollision();
+ List list = this.world.getOtherEntities(this, this.getBoundingBox().expand(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntityPredicates.canBePushedBy(this));
+ if (!list.isEmpty()) {
+ boolean bl = !this.world.isClient;
+
+ for (Entity entity : list) {
+ if (!entity.hasPassenger(this)) {
+ if (bl && this.getPassengerList().size() < 2 && !entity.hasVehicle() && entity instanceof WolfEntity && ((WolfEntity) entity).getOwner() != null && !((WolfEntity) entity).isBaby()) {
+ entity.startRiding(this);
+ } else {
+ this.pushAwayFrom(entity);
+ }
+ }
+ }
+ }
+ }
+
+ private void clientInterpolation() {
+ if (this.isLogicalSideForUpdatingMovement()) {
+ this.clientInterpolationSteps = 0;
+ this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ());
+ }
+
+ if (this.clientInterpolationSteps > 0) {
+ double d = this.getX() + (this.x - this.getX()) / (double) this.clientInterpolationSteps;
+ double e = this.getY() + (this.y - this.getY()) / (double) this.clientInterpolationSteps;
+ double f = this.getZ() + (this.z - this.getZ()) / (double) this.clientInterpolationSteps;
+ double g = MathHelper.wrapDegrees(this.dogsledYaw - (double) this.getYaw());
+ float yaw = (float) ((double) this.getYaw() + g / (double) this.clientInterpolationSteps);
+ float pitch = (float) ((double) this.getPitch() + (this.dogsledPitch - (double) this.getPitch()) / (double) this.clientInterpolationSteps);
+ --this.clientInterpolationSteps;
+ this.setPosition(d, e, f);
+ this.setRotation(yaw, pitch);
+ }
+ }
+
+ private Location checkLocation() {
+ Location location = this.getUnderWaterLocation();
+ if (location != null) {
+ this.waterLevel = this.getBoundingBox().maxY;
+ return location;
+ } else {
+ float f = this.getBlockSlipperiness();
+ if (f > 0.0F) {
+ return Location.ON_LAND;
+ } else {
+ return Location.IN_AIR;
+ }
+ }
+ }
+
+ public float getBlockSlipperiness() {
+ Box box = this.getBoundingBox();
+ Box box2 = new Box(box.minX, box.minY - 0.001D, box.minZ, box.maxX, box.minY, box.maxZ);
+ int i = MathHelper.floor(box2.minX) - 1;
+ int j = MathHelper.ceil(box2.maxX) + 1;
+ int k = MathHelper.floor(box2.minY) - 1;
+ int l = MathHelper.ceil(box2.maxY) + 1;
+ int m = MathHelper.floor(box2.minZ) - 1;
+ int n = MathHelper.ceil(box2.maxZ) + 1;
+ VoxelShape voxelShape = VoxelShapes.cuboid(box2);
+ float f = 0.0F;
+ int o = 0;
+ BlockPos.Mutable mutable = new BlockPos.Mutable();
+
+ for (int p = i; p < j; ++p) {
+ for (int q = m; q < n; ++q) {
+ int r = (p != i && p != j - 1 ? 0 : 1) + (q != m && q != n - 1 ? 0 : 1);
+ if (r != 2) {
+ for (int s = k; s < l; ++s) {
+ if (r <= 0 || s != k && s != l - 1) {
+ mutable.set(p, s, q);
+ BlockState blockState = this.world.getBlockState(mutable);
+ BlockState topBlock = this.world.getBlockState(mutable.up());
+ if (blockState.isOf(Blocks.SNOW_BLOCK) || topBlock.isOf(Blocks.SNOW)) {
+ f += 0.95F;
+ ++o;
+ } else if (!(blockState.getBlock() instanceof LilyPadBlock) && VoxelShapes.matchesAnywhere(blockState.getCollisionShape(this.world, mutable).offset(p, s, q), voxelShape, BooleanBiFunction.AND)) {
+ f += blockState.getBlock().getSlipperiness();
+ ++o;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return f / (float) o;
+ }
+
+ @Nullable
+ private Location getUnderWaterLocation() {
+ Box box = this.getBoundingBox();
+ double d = box.maxY + 0.001D;
+ int i = MathHelper.floor(box.minX);
+ int j = MathHelper.ceil(box.maxX);
+ int k = MathHelper.floor(box.maxY);
+ int l = MathHelper.ceil(d);
+ int m = MathHelper.floor(box.minZ);
+ int n = MathHelper.ceil(box.maxZ);
+ boolean bl = false;
+ BlockPos.Mutable mutable = new BlockPos.Mutable();
+
+ for (int o = i; o < j; ++o) {
+ for (int p = k; p < l; ++p) {
+ for (int q = m; q < n; ++q) {
+ mutable.set(o, p, q);
+ FluidState fluidState = this.world.getFluidState(mutable);
+ if (fluidState.isIn(FluidTags.WATER)) {
+ float f = (float) p + fluidState.getHeight(this.world, mutable);
+ this.waterLevel = Math.max(f, this.waterLevel);
+ bl |= box.minY < (double) f;
+ if (d < (double) ((float) mutable.getY() + fluidState.getHeight(this.world, mutable))) {
+ if (!fluidState.isSource()) {
+ return Location.UNDER_FLOWING_WATER;
+ }
+
+ bl = true;
+ }
+ }
+ }
+ }
+ }
+
+ return bl ? Location.UNDER_WATER : null;
+ }
+
+ private void updateMovement() {
+ if (this.hasPassengers()) {
+ float f = 0.0F;
+ if (this.pressingLeft) {
+ --this.yawVelocity;
+ }
+
+ if (this.pressingRight) {
+ ++this.yawVelocity;
+ }
+
+ if (this.pressingRight != this.pressingLeft && !this.pressingForward && !this.pressingBack) {
+ f += 0.005F;
+ }
+
+ this.setYaw(this.getYaw() + this.yawVelocity);
+ if (this.pressingForward) {
+ f += 0.04F;
+ }
+
+ if (this.pressingBack) {
+ f -= 0.005F;
+ }
+
+ this.setVelocity(this.getVelocity().add((MathHelper.sin(-this.getYaw() * 0.017453292F) * f), 0.0D, (MathHelper.cos(this.getYaw() * 0.017453292F) * f)));
+ }
+ }
+
+ private void updateVelocity() {
+ double e = this.hasNoGravity() ? 0.0D : -0.03999999910593033D;
+ double f = 0.0D;
+ if (this.location == Location.ON_LAND) {
+ this.velocityDecay = this.getBlockSlipperiness();
+ } else {
+ if (this.location == Location.UNDER_FLOWING_WATER) {
+ e = -7.0E-4D;
+ } else if (this.location == Location.UNDER_WATER) {
+ f = 0.009999999776482582D;
+ }
+
+ this.velocityDecay *= 0.95F;
+ }
+
+ if (this.getPassengerList().size() < 2) {
+ this.velocityDecay /= 1.15F;
+ }
+
+ Vec3d vec3d = this.getVelocity();
+ this.setVelocity(vec3d.x * (double) this.velocityDecay, vec3d.y + e, vec3d.z * (double) this.velocityDecay);
+ this.yawVelocity *= this.velocityDecay / 1.5F;
+ if (f > 0.0D) {
+ Vec3d vec3d2 = this.getVelocity();
+ this.setVelocity(vec3d2.x, (vec3d2.y + f * 0.06153846016296973D) * 0.75D, vec3d2.z);
+ }
+ }
+
+ @Override
+ public Vec3d updatePassengerForDismount(@NotNull LivingEntity passenger) {
+ Vec3d vec3d = getPassengerDismountOffset((this.getWidth() * MathHelper.SQUARE_ROOT_OF_TWO), passenger.getWidth(), passenger.getYaw());
+ double d = this.getX() + vec3d.x;
+ double e = this.getZ() + vec3d.z;
+ BlockPos blockPos = new BlockPos(d, this.getBoundingBox().maxY, e);
+ BlockPos blockPos2 = blockPos.down();
+ if (!this.world.isWater(blockPos2)) {
+ List list = Lists.newArrayList();
+ double f = this.world.getDismountHeight(blockPos);
+ if (Dismounting.canDismountInBlock(f)) {
+ list.add(new Vec3d(d, (double) blockPos.getY() + f, e));
+ }
+
+ double g = this.world.getDismountHeight(blockPos2);
+ if (Dismounting.canDismountInBlock(g)) {
+ list.add(new Vec3d(d, (double) blockPos2.getY() + g, e));
+ }
+
+ for (EntityPose entityPose : passenger.getPoses()) {
+ for (Vec3d vec3d2 : list) {
+ if (Dismounting.canPlaceEntityAt(this.world, vec3d2, passenger, entityPose)) {
+ passenger.setPose(entityPose);
+ return vec3d2;
+ }
+ }
+ }
+ }
+
+ return super.updatePassengerForDismount(passenger);
+ }
+
+ protected void copyEntityData(@NotNull Entity entity) {
+ entity.setBodyYaw(this.getYaw());
+ float f = MathHelper.wrapDegrees(entity.getYaw() - this.getYaw());
+ float g = MathHelper.clamp(f, -105.0F, 105.0F);
+ entity.prevYaw += (g - f);
+ entity.setYaw(entity.getYaw() + g - f);
+ entity.setHeadYaw(entity.getYaw());
+ }
+
+ @Override
+ @Environment(EnvType.CLIENT)
+ public void onPassengerLookAround(Entity passenger) {
+ this.copyEntityData(passenger);
+ }
+
+ @Override
+ protected void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) {
+ if (!this.hasVehicle()) {
+ if (onGround) {
+ if (this.fallDistance > 3.0F) {
+ if (this.location != Location.ON_LAND) {
+ this.fallDistance = 0.0F;
+ return;
+ }
+
+ this.handleFallDamage(this.fallDistance, 1.0F, DamageSource.FALL);
+ if (!this.world.isClient && !this.isRemoved()) {
+ this.kill();
+ if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
+ int j;
+ for (j = 0; j < 3; ++j) {
+ this.dropItem(this.getDogsledType().getBaseBlock());
+ }
+
+ for (j = 0; j < 2; ++j) {
+ this.dropItem(Items.STICK);
+ }
+
+ this.dropItems(null);
+ }
+ }
+ }
+
+ this.fallDistance = 0.0F;
+ } else if (!this.world.getFluidState(this.getBlockPos().down()).isIn(FluidTags.WATER) && heightDifference < 0.0D) {
+ this.fallDistance = (float) ((double) this.fallDistance - heightDifference);
+ }
+ }
+ }
+
+ public float getDamageWobbleStrength() {
+ return this.dataTracker.get(DAMAGE_WOBBLE_STRENGTH);
+ }
+
+ public void setDamageWobbleStrength(float wobbleStrength) {
+ this.dataTracker.set(DAMAGE_WOBBLE_STRENGTH, wobbleStrength);
+ }
+
+ public int getDamageWobbleTicks() {
+ return this.dataTracker.get(DAMAGE_WOBBLE_TICKS);
+ }
+
+ public void setDamageWobbleTicks(int wobbleTicks) {
+ this.dataTracker.set(DAMAGE_WOBBLE_TICKS, wobbleTicks);
+ }
+
+ public int getDamageWobbleSide() {
+ return this.dataTracker.get(DAMAGE_WOBBLE_SIDE);
+ }
+
+ public void setDamageWobbleSide(int side) {
+ this.dataTracker.set(DAMAGE_WOBBLE_SIDE, side);
+ }
+
+ public DogsledEntity.Type getDogsledType() {
+ return DogsledEntity.Type.getType(this.dataTracker.get(DOGSLED_TYPE));
+ }
+
+ public void setDogsledType(@NotNull DogsledEntity.Type type) {
+ this.dataTracker.set(DOGSLED_TYPE, type.ordinal());
+ }
+
+ @Override
+ protected boolean canAddPassenger(Entity passenger) {
+ int i = this.getPassengerList().size();
+ if (this.isSubmergedIn(FluidTags.WATER)) {
+ return false;
+ }
+
+ if (i == 0) {
+ return passenger instanceof PlayerEntity || passenger instanceof WolfEntity;
+ } else if (i == 1) {
+ return passenger instanceof PlayerEntity;
+ }
+
+ return false;
+ }
+
+ @Override
+ @Nullable
+ public Entity getPrimaryPassenger() {
+ List list = this.getPassengerList();
+ return list.isEmpty() ? null : list.get(0);
+ }
+
+ @Override
+ public boolean isSubmergedInWater() {
+ return this.location == Location.UNDER_WATER || this.location == Location.UNDER_FLOWING_WATER;
+ }
+
+ @Override
+ public Packet> createSpawnPacket() {
+ return new EntitySpawnS2CPacket(this);
+ }
+
+ @Environment(EnvType.CLIENT)
+ public void setInputs(boolean pressingLeft, boolean pressingRight, boolean pressingForward, boolean pressingBack) {
+ this.pressingLeft = pressingLeft;
+ this.pressingRight = pressingRight;
+ this.pressingForward = pressingForward;
+ this.pressingBack = pressingBack;
+ }
+
+ @Override
+ public int size() {
+ return 27;
+ }
+
+ @Override
+ public double getMountedHeightOffset() {
+ return 0.2D;
+ }
+
+ @Override
+ public boolean damage(DamageSource source, float amount) {
+ if (!this.world.isClient && !this.isRemoved()) {
+ if (this.isInvulnerableTo(source)) {
+ return false;
+ } else {
+ this.setDamageWobbleSide(-this.getDamageWobbleSide());
+ this.setDamageWobbleTicks(10);
+ this.scheduleVelocityUpdate();
+ this.setDamageWobbleStrength(this.getDamageWobbleStrength() + amount * 10.0F);
+ boolean bl = source.getAttacker() instanceof PlayerEntity && ((PlayerEntity) source.getAttacker()).getAbilities().creativeMode;
+ if (bl || this.getDamageWobbleStrength() > 40.0F) {
+ this.removeAllPassengers();
+ if (bl && !this.hasCustomName()) {
+ this.discard();
+ } else {
+ this.dropItems(source);
+ }
+ }
+
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+
+ @Override
+ public void removeAllPassengers() {
+ for (int i = this.getPassengerList().size() - 1; i >= 0; --i) {
+ Entity entity = this.getPassengerList().get(i);
+ if (entity instanceof WolfEntity) {
+ entity.noClip = false;
+ }
+
+ entity.stopRiding();
+ }
+ }
+
+ public void dropItems(DamageSource damageSource) {
+ this.remove(RemovalReason.KILLED);
+ if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
+ if (damageSource != null) {
+ ItemStack itemStack = this.asItem().getDefaultStack();
+ if (this.hasCustomName()) {
+ itemStack.setCustomName(this.getCustomName());
+ }
+
+ this.dropStack(itemStack);
+ }
+
+ ItemScatterer.spawn(this.world, this, this);
+ if (damageSource != null && !this.world.isClient) {
+ Entity entity = damageSource.getSource();
+ if (entity != null && entity.getType() == EntityType.PLAYER) {
+ PiglinBrain.onGuardedBlockInteracted((PlayerEntity) entity, true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void updatePassengerPosition(Entity passenger) {
+ this.updatePassengerPosition(passenger, Entity::setPosition);
+ }
+
+ private void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) {
+ if (this.hasPassenger(passenger)) {
+ if (passenger instanceof PlayerEntity) {
+ float g = (float) ((this.isRemoved() ? 0.009999999776482582D : this.getMountedHeightOffset()) + passenger.getHeightOffset());
+ double x = MathHelper.cos((this.getYaw() + 90.0F) * 0.0174533F);
+ double z = MathHelper.sin((this.getYaw() + 90.0F) * 0.0174533F);
+ positionUpdater.accept(passenger, this.getX() - x, this.getY() + (double) g, this.getZ() - z);
+ } else if (passenger instanceof WolfEntity) {
+ passenger.noClip = true;
+ Vec3d vec3d = (new Vec3d(1.5D, 0.0D, 0.0D)).rotateY(-this.getYaw() * 0.017453292F - 1.5707964F);
+ positionUpdater.accept(passenger, this.getX() + vec3d.x, this.getY(), this.getZ() + vec3d.z);
+ passenger.setYaw(passenger.getYaw() + this.yawVelocity);
+ passenger.setHeadYaw(passenger.getHeadYaw() + this.yawVelocity);
+ this.copyEntityData(passenger);
+ }
+ }
+ }
+
+ @Override
+ public void writeCustomDataToNbt(@NotNull NbtCompound tag) {
+ tag.putString("Type", this.getDogsledType().getName());
+ if (this.lootTableId != null) {
+ tag.putString("LootTable", this.lootTableId.toString());
+ if (this.lootSeed != 0L) {
+ tag.putLong("LootTableSeed", this.lootSeed);
+ }
+ } else {
+ Inventories.writeNbt(tag, this.inventory);
+ }
+ }
+
+ @Override
+ public void readCustomDataFromNbt(@NotNull NbtCompound tag) {
+ if (tag.contains("Type", 8)) {
+ this.setDogsledType(DogsledEntity.Type.getType(tag.getString("Type")));
+ }
+
+ this.inventory = DefaultedList.ofSize(this.size(), ItemStack.EMPTY);
+ if (tag.contains("LootTable", 8)) {
+ this.lootTableId = new Identifier(tag.getString("LootTable"));
+ this.lootSeed = tag.getLong("LootTableSeed");
+ } else {
+ Inventories.readNbt(tag, this.inventory);
+ }
+ }
+
+ @Override
+ public ActionResult interact(@NotNull PlayerEntity player, Hand hand) {
+ if (player.isSneaking()) {
+ player.openHandledScreen(this);
+ if (!player.world.isClient) {
+ PiglinBrain.onGuardedBlockInteracted(player, true);
+ return ActionResult.CONSUME;
+ } else {
+ return ActionResult.SUCCESS;
+ }
+ } else {
+ if (this.ticksUnderwater < 60.0F) {
+ if (!this.world.isClient) {
+ return player.startRiding(this) ? ActionResult.CONSUME : ActionResult.PASS;
+ } else {
+ return ActionResult.SUCCESS;
+ }
+ } else {
+ return ActionResult.PASS;
+ }
+ }
+ }
+
+ @Override
+ public boolean isEmpty() {
+ Iterator var1 = this.inventory.iterator();
+
+ ItemStack itemStack;
+ do {
+ if (!var1.hasNext()) {
+ return true;
+ }
+
+ itemStack = var1.next();
+ } while (itemStack.isEmpty());
+
+ return false;
+ }
+
+ @Override
+ public ItemStack getStack(int slot) {
+ this.generateLoot(null);
+ return this.inventory.get(slot);
+ }
+
+ @Override
+ public ItemStack removeStack(int slot, int amount) {
+ this.generateLoot(null);
+ return Inventories.splitStack(this.inventory, slot, amount);
+ }
+
+ @Override
+ public ItemStack removeStack(int slot) {
+ this.generateLoot(null);
+ ItemStack itemStack = this.inventory.get(slot);
+ if (itemStack.isEmpty()) {
+ return ItemStack.EMPTY;
+ } else {
+ this.inventory.set(slot, ItemStack.EMPTY);
+ return itemStack;
+ }
+ }
+
+ @Override
+ public void setStack(int slot, ItemStack stack) {
+ this.generateLoot(null);
+ this.inventory.set(slot, stack);
+ if (!stack.isEmpty() && stack.getCount() > this.getMaxCountPerStack()) {
+ stack.setCount(this.getMaxCountPerStack());
+ }
+ }
+
+ public boolean equip(int slot, ItemStack item) {
+ if (slot >= 0 && slot < this.size()) {
+ this.setStack(slot, item);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void markDirty() {
+ }
+
+ @Override
+ public boolean canPlayerUse(PlayerEntity player) {
+ if (this.isRemoved()) {
+ return false;
+ } else {
+ return player.squaredDistanceTo(this) <= 64.0D;
+ }
+ }
+
+ public void generateLoot(@Nullable PlayerEntity player) {
+ if (this.lootTableId != null && this.world.getServer() != null) {
+ LootTable lootTable = this.world.getServer().getLootManager().getTable(this.lootTableId);
+ if (player instanceof ServerPlayerEntity) {
+ Criteria.PLAYER_GENERATES_CONTAINER_LOOT.trigger((ServerPlayerEntity) player, this.lootTableId);
+ }
+
+ this.lootTableId = null;
+ LootContext.Builder builder = (new LootContext.Builder((ServerWorld) this.world)).parameter(LootContextParameters.ORIGIN, this.getPos()).random(this.lootSeed);
+ if (player != null) {
+ builder.luck(player.getLuck()).parameter(LootContextParameters.THIS_ENTITY, player);
+ }
+
+ lootTable.supplyInventory(this, builder.build(LootContextTypes.CHEST));
+ }
+ }
+
+ @Override
+ public void clear() {
+ this.generateLoot(null);
+ this.inventory.clear();
+ }
+
+ public void setLootTable(Identifier id, long lootSeed) {
+ this.lootTableId = id;
+ this.lootSeed = lootSeed;
+ }
+
+ @Override
+ @Nullable
+ public ScreenHandler createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) {
+ if (this.lootTableId != null && playerEntity.isSpectator()) {
+ return null;
+ } else {
+ this.generateLoot(playerInventory.player);
+ return this.getScreenHandler(i, playerInventory);
+ }
+ }
+
+ public ScreenHandler getScreenHandler(int syncId, PlayerInventory playerInventory) {
+ return GenericContainerScreenHandler.createGeneric9x3(syncId, playerInventory, this);
+ }
+
+ public enum Type {
+ OAK(Blocks.OAK_PLANKS, "oak"),
+ SPRUCE(Blocks.SPRUCE_PLANKS, "spruce"),
+ BIRCH(Blocks.BIRCH_PLANKS, "birch"),
+ JUNGLE(Blocks.JUNGLE_PLANKS, "jungle"),
+ ACACIA(Blocks.ACACIA_PLANKS, "acacia"),
+ DARK_OAK(Blocks.DARK_OAK_PLANKS, "dark_oak");
+
+ private final String name;
+ private final Block baseBlock;
+
+ Type(Block baseBlock, String name) {
+ this.name = name;
+ this.baseBlock = baseBlock;
+ }
+
+ public static DogsledEntity.Type getType(int i) {
+ DogsledEntity.Type[] types = values();
+ if (i < 0 || i >= types.length) {
+ i = 0;
+ }
+
+ return types[i];
+ }
+
+ public static DogsledEntity.Type getType(String string) {
+ DogsledEntity.Type[] types = values();
+
+ for (Type type : types) {
+ if (type.getName().equals(string)) {
+ return type;
+ }
+ }
+
+ return types[0];
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public Block getBaseBlock() {
+ return this.baseBlock;
+ }
+
+ public String toString() {
+ return this.name;
+ }
+ }
+
+ public enum Location {
+ UNDER_WATER,
+ UNDER_FLOWING_WATER,
+ ON_LAND,
+ IN_AIR
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java
index 63cd044d..03385f12 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java
@@ -5,7 +5,9 @@
import io.netty.buffer.Unpooled;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
@@ -36,322 +38,327 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+
+import org.quiltmc.qsl.networking.api.ServerPlayNetworking;
public class HarpoonEntity extends PersistentProjectileEntity {
- public static final Identifier SPAWN_PACKET = new Identifier(AlaskaNativeCraft.MOD_ID, "harpoon_entity");
- private static final TrackedData LOYALTY;
- private static final TrackedData ENCHANTED;
-
- static {
- ENCHANTED = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
- LOYALTY = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BYTE);
- }
-
- public int returnTimer;
- private ItemStack harpoonStack;
- private HarpoonEntity.State state;
- private boolean dealtDamage;
-
- public HarpoonEntity(EntityType extends HarpoonEntity> entityType, World world, HarpoonItem item) {
- super(entityType, world);
- this.state = HarpoonEntity.State.FLYING;
- this.harpoonStack = new ItemStack(item);
- }
-
- public HarpoonEntity(World world, LivingEntity owner, @NotNull HarpoonItem item, @NotNull ItemStack stack) {
- super(item.getType(), owner, world);
- this.harpoonStack = stack.copy();
- this.state = HarpoonEntity.State.FLYING;
- this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack));
- this.dataTracker.set(ENCHANTED, stack.hasGlint());
- }
-
- public static DamageSource createHarpoonDamageSource(Entity harpoon, Entity owner) {
- return new ProjectileDamageSource("harpoon", harpoon, owner).setProjectile();
- }
-
- @Override
- protected void initDataTracker() {
- super.initDataTracker();
- this.dataTracker.startTracking(LOYALTY, (byte) 0);
- this.dataTracker.startTracking(ENCHANTED, false);
- }
-
- @Override
- public Packet> createSpawnPacket() {
- PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer());
-
- packet.writeVarInt(Registry.ENTITY_TYPE.getRawId(this.getType()));
- packet.writeUuid(this.getUuid());
- packet.writeVarInt(this.getId());
- packet.writeDouble(this.getX());
- packet.writeDouble(this.getY());
- packet.writeDouble(this.getZ());
- packet.writeByte(MathHelper.floor(this.getPitch() * 256.0F / 360.0F));
- packet.writeByte(MathHelper.floor(this.getYaw() * 256.0F / 360.0F));
-
- return ServerPlayNetworking.createS2CPacket(SPAWN_PACKET, packet);
- }
-
- @Override
- protected ItemStack asItemStack() {
- return this.harpoonStack.copy();
- }
-
- @Environment(EnvType.CLIENT)
- public boolean isEnchanted() {
- return this.dataTracker.get(ENCHANTED);
- }
-
- @Override
- @Nullable
- protected EntityHitResult getEntityCollision(Vec3d currentPosition, Vec3d nextPosition) {
- return this.dealtDamage ? null : super.getEntityCollision(currentPosition, nextPosition);
- }
-
- @Override
- public void tick() {
- if (this.state == State.BOBBING) {
- float fluidHeight = 0.0F;
- BlockPos blockPos = this.getBlockPos();
- FluidState fluidState = this.world.getFluidState(blockPos);
- if (fluidState.isIn(FluidTags.WATER)) {
- fluidHeight = fluidState.getHeight(this.world, blockPos);
- }
- Vec3d vec3d = this.getVelocity();
- double distanceFromLiquidHeight = this.getY() + vec3d.y - (double) blockPos.getY() - (double) fluidHeight;
-
- // Set pitch, zero it if its minimal.
- if (vec3d.y > 0.032D) {
- this.setPitch((float) (MathHelper.atan2(vec3d.y, vec3d.horizontalLength()) * 57.2957763671875D));
- this.setPitch(updateRotation(this.prevPitch, this.getPitch()));
- } else {
- this.setPitch(updateRotation(this.prevPitch, 0.0F));
- }
-
- // Get bobbing action
- if (Math.abs(distanceFromLiquidHeight) < 0.01D) {
- distanceFromLiquidHeight += Math.signum(distanceFromLiquidHeight) * 0.1D;
- }
- this.setVelocity(vec3d.x * 0.9D, vec3d.y - distanceFromLiquidHeight * (double) this.random.nextFloat() * 0.2D, vec3d.z * 0.9D);
- vec3d = this.getVelocity();
- this.setPosition(this.getX() + vec3d.x, this.getY() + vec3d.y, this.getZ() + vec3d.z);
- this.checkBlockCollision();
- return;
- }
-
- if (this.inGroundTime > 4) {
- this.dealtDamage = true;
- }
-
- Entity entity = this.getOwner();
- if ((this.dealtDamage || this.isNoClip()) && entity != null) {
- int i = this.dataTracker.get(LOYALTY);
- if (i > 0 && !entity.isAlive()) {
- if (!this.world.isClient && this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED) {
- this.dropStack(this.asItemStack(), 0.1F);
- }
-
- this.discard();
- } else if (i > 0) {
- this.setNoClip(true);
- Vec3d vec3d = new Vec3d(entity.getX() - this.getX(), entity.getEyeY() - this.getY(), entity.getZ() - this.getZ());
- this.setPos(this.getX(), this.getY() + vec3d.y * 0.015D * (double) i, this.getZ());
- if (this.world.isClient) {
- this.lastRenderY = this.getY();
- }
-
- double d = 0.05D * (double) i;
- this.setVelocity(this.getVelocity().multiply(0.95D).add(vec3d.normalize().multiply(d)));
- if (this.returnTimer == 0) {
- this.playSound(SoundEvents.ITEM_TRIDENT_RETURN, 10.0F, 1.0F);
- }
-
- ++this.returnTimer;
- }
- }
-
- super.tick();
- boolean inWater = this.isTouchingWater();
-
- // We don't change anything unless the Harpoon is underwater
- if (this.inGround && this.state != State.LANDED) {
- this.state = State.LANDED;
- return;
- } else if (!inWater || this.state != State.FLYING) {
- return;
- }
-
- // Harpoon must be underwater
-
- // Revert previous fall calculations
- Vec3d velocity = this.getVelocity();
- double d = velocity.x;
- double e = velocity.y + 0.05D;
- double g = velocity.z;
- this.setVelocity(d, e, g);
-
- double h = this.getX() - d;
- double j = this.getY() - e;
- double k = this.getZ() - g;
-
- // Now do regular tick stuff
- float f = 0.0F;
- BlockPos blockPos = this.getBlockPos();
- FluidState fluidState = this.world.getFluidState(blockPos);
- if (fluidState.isIn(FluidTags.WATER)) {
- f = fluidState.getHeight(this.world, blockPos);
- }
- velocity = this.getVelocity();
- double distanceFromLiquidHeight = this.getY() + velocity.y - (double) blockPos.getY() - (double) f;
-
- // The harpoon is still flying through water, so make it buoyant
- if (distanceFromLiquidHeight > 0.0D && velocity.length() < 1) {
- this.state = State.BOBBING;
- } else {
- this.setVelocity(velocity.x, velocity.y + 0.025D, velocity.z);
- }
-
- velocity = this.getVelocity().multiply(this.getDragInWater());
- h += velocity.x;
- j += velocity.y;
- k += velocity.z;
- this.setPosition(h, j, k);
- this.checkBlockCollision();
- }
-
- @Override
- protected void checkBlockCollision() {
- super.checkBlockCollision();
- if (this.inGround) {
- this.state = State.LANDED;
- }
- }
-
- @SuppressWarnings("ConstantConditions")
- @Override
- protected void onEntityHit(@NotNull EntityHitResult entityHitResult) {
- Entity hitEntity = entityHitResult.getEntity();
- float f = ((HarpoonItem) this.harpoonStack.getItem()).getAttackDamage();
- if (hitEntity instanceof LivingEntity livingHitEntity) {
- f += EnchantmentHelper.getAttackDamage(this.harpoonStack, livingHitEntity.getGroup());
- }
-
- Entity owner = this.getOwner();
- DamageSource damageSource = createHarpoonDamageSource(this, (owner == null ? this : owner));
- this.dealtDamage = true;
- SoundEvent soundEvent = SoundEvents.ITEM_TRIDENT_HIT;
- if (hitEntity.damage(damageSource, f)) {
- if (hitEntity.getType() == EntityType.ENDERMAN) {
- return;
- }
-
- if (hitEntity instanceof LivingEntity livingHitEntity) {
- if (owner instanceof LivingEntity) {
- EnchantmentHelper.onUserDamaged(livingHitEntity, owner);
- EnchantmentHelper.onTargetDamaged((LivingEntity) owner, livingHitEntity);
- }
-
- this.onHit(livingHitEntity);
-
- if (hitEntity instanceof MobEntity && this.getOwner() instanceof PlayerEntity && !((MobEntity) hitEntity).isLeashed() && this.harpoonStack.getOrCreateNbt().contains("leashed") && this.harpoonStack.getOrCreateNbt().getBoolean("leashed")) {
- ((MobEntity) hitEntity).attachLeash(this.getOwner(), true);
- // Chance to lose the leash, based on level of Loyalty
- // 100% at 0, 50% at 1, 33% at 2, etc.
- if (this.random.nextInt(this.dataTracker.get(LOYALTY) + 1) == 0) {
- this.harpoonStack.removeSubNbt("leashed");
- }
- this.setVelocity(Vec3d.ZERO);
- this.playSound(soundEvent, 1.0F, 1.0F);
- return;
- }
- }
- }
-
- float g = 1.0F;
- if (this.world instanceof ServerWorld && this.world.isThundering() && EnchantmentHelper.hasChanneling(this.harpoonStack)) {
- BlockPos blockPos = hitEntity.getBlockPos();
- if (this.world.isSkyVisible(blockPos)) {
- LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(this.world);
- lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(blockPos));
- lightningEntity.setChanneler(owner instanceof ServerPlayerEntity ? (ServerPlayerEntity) owner : null);
- this.world.spawnEntity(lightningEntity);
- soundEvent = SoundEvents.ITEM_TRIDENT_THUNDER;
- g = 5.0F;
- }
- }
-
- this.playSound(soundEvent, g, 1.0F);
-
- this.setVelocity(this.getVelocity().multiply(-0.01D, -0.1D, -0.01D));
- this.playSound(soundEvent, 1.0F, 1.0F);
- }
-
- @Override
- protected SoundEvent getHitSound() {
- return SoundEvents.ITEM_TRIDENT_HIT_GROUND;
- }
-
- @Override
- public void onPlayerCollision(PlayerEntity player) {
- Entity entity = this.getOwner();
- if (entity == null || entity.getUuid() == player.getUuid()) {
- if (this.state != State.FLYING && !this.world.isClient && (this.state == State.BOBBING || this.isNoClip()) && this.shake <= 0) {
- boolean bl = this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED || this.pickupType == PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY && player.getAbilities().creativeMode || this.isNoClip() && this.getOwner().getUuid() == player.getUuid();
- if (this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED && !player.getInventory().insertStack(this.asItemStack())) {
- bl = false;
- }
-
- if (bl) {
- player.sendPickup(this, 1);
- this.discard();
- }
- } else
- super.onPlayerCollision(player);
- }
- }
-
- @Override
- public void readCustomDataFromNbt(NbtCompound tag) {
- super.readCustomDataFromNbt(tag);
- if (tag.contains("Trident", 10)) {
- this.harpoonStack = ItemStack.fromNbt(tag.getCompound("Harpoon"));
- }
-
- this.dealtDamage = tag.getBoolean("DealtDamage");
- }
-
- @Override
- public void writeCustomDataToNbt(NbtCompound tag) {
- super.writeCustomDataToNbt(tag);
- tag.put("Harpoon", this.harpoonStack.writeNbt(new NbtCompound()));
- tag.putBoolean("DealtDamage", this.dealtDamage);
- }
-
- @Override
- public void age() {
- if (this.pickupType != PersistentProjectileEntity.PickupPermission.ALLOWED) {
- super.age();
- }
- }
-
- @Override
- protected float getDragInWater() {
- return 0.9F;
- }
-
- @Override
- @Environment(EnvType.CLIENT)
- public boolean shouldRender(double cameraX, double cameraY, double cameraZ) {
- return true;
- }
-
- enum State {
- FLYING,
- HOOKED_IN_ENTITY,
- BOBBING,
- LANDED
- }
+ public static final Identifier SPAWN_PACKET = new Identifier(AlaskaNativeCraft.MOD_ID, "harpoon_entity");
+ private static final TrackedData LOYALTY;
+ private static final TrackedData ENCHANTED;
+
+ static {
+ ENCHANTED = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
+ LOYALTY = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BYTE);
+ }
+
+ public int returnTimer;
+ private ItemStack harpoonStack;
+ private HarpoonEntity.State state;
+ private boolean dealtDamage;
+
+ public HarpoonEntity(EntityType extends HarpoonEntity> entityType, World world, HarpoonItem item) {
+ super(entityType, world);
+ this.state = HarpoonEntity.State.FLYING;
+ this.harpoonStack = new ItemStack(item);
+ }
+
+ public HarpoonEntity(World world, LivingEntity owner, @NotNull HarpoonItem item, @NotNull ItemStack stack) {
+ super(item.getType(), owner, world);
+ this.harpoonStack = stack.copy();
+ this.state = HarpoonEntity.State.FLYING;
+ this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack));
+ this.dataTracker.set(ENCHANTED, stack.hasGlint());
+ }
+
+ public static DamageSource createHarpoonDamageSource(Entity harpoon, Entity owner) {
+ return new ProjectileDamageSource("harpoon", harpoon, owner).setProjectile();
+ }
+
+ @Override
+ protected void initDataTracker() {
+ super.initDataTracker();
+ this.dataTracker.startTracking(LOYALTY, (byte) 0);
+ this.dataTracker.startTracking(ENCHANTED, false);
+ }
+
+ @Override
+ public Packet> createSpawnPacket() {
+ PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer());
+
+ packet.writeVarInt(Registry.ENTITY_TYPE.getRawId(this.getType()));
+ packet.writeUuid(this.getUuid());
+ packet.writeVarInt(this.getId());
+ packet.writeDouble(this.getX());
+ packet.writeDouble(this.getY());
+ packet.writeDouble(this.getZ());
+ packet.writeByte(MathHelper.floor(this.getPitch() * 256.0F / 360.0F));
+ packet.writeByte(MathHelper.floor(this.getYaw() * 256.0F / 360.0F));
+
+ return ServerPlayNetworking.createS2CPacket(SPAWN_PACKET, packet);
+ }
+
+ @Override
+ protected ItemStack asItemStack() {
+ return this.harpoonStack.copy();
+ }
+
+ @Environment(EnvType.CLIENT)
+ public boolean isEnchanted() {
+ return this.dataTracker.get(ENCHANTED);
+ }
+
+ @Override
+ @Nullable
+ protected EntityHitResult getEntityCollision(Vec3d currentPosition, Vec3d nextPosition) {
+ return this.dealtDamage ? null : super.getEntityCollision(currentPosition, nextPosition);
+ }
+
+ @Override
+ public void tick() {
+ if (this.state == State.BOBBING) {
+ float fluidHeight = 0.0F;
+ BlockPos blockPos = this.getBlockPos();
+ FluidState fluidState = this.world.getFluidState(blockPos);
+ if (fluidState.isIn(FluidTags.WATER)) {
+ fluidHeight = fluidState.getHeight(this.world, blockPos);
+ }
+
+ Vec3d vec3d = this.getVelocity();
+ double distanceFromLiquidHeight = this.getY() + vec3d.y - (double) blockPos.getY() - (double) fluidHeight;
+
+ // Set pitch, zero it if its minimal.
+ if (vec3d.y > 0.032D) {
+ this.setPitch((float) (MathHelper.atan2(vec3d.y, vec3d.horizontalLength()) * 57.2957763671875D));
+ this.setPitch(updateRotation(this.prevPitch, this.getPitch()));
+ } else {
+ this.setPitch(updateRotation(this.prevPitch, 0.0F));
+ }
+
+ // Get bobbing action
+ if (Math.abs(distanceFromLiquidHeight) < 0.01D) {
+ distanceFromLiquidHeight += Math.signum(distanceFromLiquidHeight) * 0.1D;
+ }
+
+ this.setVelocity(vec3d.x * 0.9D, vec3d.y - distanceFromLiquidHeight * (double) this.random.nextFloat() * 0.2D, vec3d.z * 0.9D);
+ vec3d = this.getVelocity();
+ this.setPosition(this.getX() + vec3d.x, this.getY() + vec3d.y, this.getZ() + vec3d.z);
+ this.checkBlockCollision();
+
+ return;
+ }
+
+ if (this.inGroundTime > 4) {
+ this.dealtDamage = true;
+ }
+
+ Entity entity = this.getOwner();
+ if ((this.dealtDamage || this.isNoClip()) && entity != null) {
+ int i = this.dataTracker.get(LOYALTY);
+ if (i > 0 && !entity.isAlive()) {
+ if (!this.world.isClient && this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED) {
+ this.dropStack(this.asItemStack(), 0.1F);
+ }
+
+ this.discard();
+ } else if (i > 0) {
+ this.setNoClip(true);
+ Vec3d vec3d = new Vec3d(entity.getX() - this.getX(), entity.getEyeY() - this.getY(), entity.getZ() - this.getZ());
+ this.setPos(this.getX(), this.getY() + vec3d.y * 0.015D * (double) i, this.getZ());
+ if (this.world.isClient) {
+ this.lastRenderY = this.getY();
+ }
+
+ double d = 0.05D * (double) i;
+ this.setVelocity(this.getVelocity().multiply(0.95D).add(vec3d.normalize().multiply(d)));
+ if (this.returnTimer == 0) {
+ this.playSound(SoundEvents.ITEM_TRIDENT_RETURN, 10.0F, 1.0F);
+ }
+
+ ++this.returnTimer;
+ }
+ }
+
+ super.tick();
+ boolean inWater = this.isTouchingWater();
+
+ // We don't change anything unless the Harpoon is underwater
+ if (this.inGround && this.state != State.LANDED) {
+ this.state = State.LANDED;
+ return;
+ } else if (!inWater || this.state != State.FLYING) {
+ return;
+ }
+
+ // Harpoon must be underwater
+
+ // Revert previous fall calculations
+ Vec3d velocity = this.getVelocity();
+ double d = velocity.x;
+ double e = velocity.y + 0.05D;
+ double g = velocity.z;
+ this.setVelocity(d, e, g);
+
+ double h = this.getX() - d;
+ double j = this.getY() - e;
+ double k = this.getZ() - g;
+
+ // Now do regular tick stuff
+ float f = 0.0F;
+ BlockPos blockPos = this.getBlockPos();
+ FluidState fluidState = this.world.getFluidState(blockPos);
+ if (fluidState.isIn(FluidTags.WATER)) {
+ f = fluidState.getHeight(this.world, blockPos);
+ }
+
+ velocity = this.getVelocity();
+ double distanceFromLiquidHeight = this.getY() + velocity.y - (double) blockPos.getY() - (double) f;
+
+ // The harpoon is still flying through water, so make it buoyant
+ if (distanceFromLiquidHeight > 0.0D && velocity.length() < 1) {
+ this.state = State.BOBBING;
+ } else {
+ this.setVelocity(velocity.x, velocity.y + 0.025D, velocity.z);
+ }
+
+ velocity = this.getVelocity().multiply(this.getDragInWater());
+ h += velocity.x;
+ j += velocity.y;
+ k += velocity.z;
+ this.setPosition(h, j, k);
+ this.checkBlockCollision();
+ }
+
+ @Override
+ protected void checkBlockCollision() {
+ super.checkBlockCollision();
+ if (this.inGround) {
+ this.state = State.LANDED;
+ }
+ }
+
+ @SuppressWarnings("ConstantConditions")
+ @Override
+ protected void onEntityHit(@NotNull EntityHitResult entityHitResult) {
+ Entity hitEntity = entityHitResult.getEntity();
+ float f = ((HarpoonItem) this.harpoonStack.getItem()).getAttackDamage();
+ if (hitEntity instanceof LivingEntity livingHitEntity) {
+ f += EnchantmentHelper.getAttackDamage(this.harpoonStack, livingHitEntity.getGroup());
+ }
+
+ Entity owner = this.getOwner();
+ DamageSource damageSource = createHarpoonDamageSource(this, (owner == null ? this : owner));
+ this.dealtDamage = true;
+ SoundEvent soundEvent = SoundEvents.ITEM_TRIDENT_HIT;
+ if (hitEntity.damage(damageSource, f)) {
+ if (hitEntity.getType() == EntityType.ENDERMAN) {
+ return;
+ }
+
+ if (hitEntity instanceof LivingEntity livingHitEntity) {
+ if (owner instanceof LivingEntity) {
+ EnchantmentHelper.onUserDamaged(livingHitEntity, owner);
+ EnchantmentHelper.onTargetDamaged((LivingEntity) owner, livingHitEntity);
+ }
+
+ this.onHit(livingHitEntity);
+
+ if (hitEntity instanceof MobEntity && this.getOwner() instanceof PlayerEntity && !((MobEntity) hitEntity).isLeashed() && this.harpoonStack.getOrCreateNbt().contains("leashed") && this.harpoonStack.getOrCreateNbt().getBoolean("leashed")) {
+ ((MobEntity) hitEntity).attachLeash(this.getOwner(), true);
+ // Chance to lose the leash, based on level of Loyalty
+ // 100% at 0, 50% at 1, 33% at 2, etc.
+ if (this.random.nextInt(this.dataTracker.get(LOYALTY) + 1) == 0) {
+ this.harpoonStack.removeSubNbt("leashed");
+ }
+
+ this.setVelocity(Vec3d.ZERO);
+ this.playSound(soundEvent, 1.0F, 1.0F);
+ return;
+ }
+ }
+ }
+
+ float g = 1.0F;
+ if (this.world instanceof ServerWorld && this.world.isThundering() && EnchantmentHelper.hasChanneling(this.harpoonStack)) {
+ BlockPos blockPos = hitEntity.getBlockPos();
+ if (this.world.isSkyVisible(blockPos)) {
+ LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(this.world);
+ lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(blockPos));
+ lightningEntity.setChanneler(owner instanceof ServerPlayerEntity ? (ServerPlayerEntity) owner : null);
+ this.world.spawnEntity(lightningEntity);
+ soundEvent = SoundEvents.ITEM_TRIDENT_THUNDER;
+ g = 5.0F;
+ }
+ }
+
+ this.playSound(soundEvent, g, 1.0F);
+
+ this.setVelocity(this.getVelocity().multiply(-0.01D, -0.1D, -0.01D));
+ this.playSound(soundEvent, 1.0F, 1.0F);
+ }
+
+ @Override
+ protected SoundEvent getHitSound() {
+ return SoundEvents.ITEM_TRIDENT_HIT_GROUND;
+ }
+
+ @Override
+ public void onPlayerCollision(PlayerEntity player) {
+ Entity entity = this.getOwner();
+ if (entity == null || entity.getUuid() == player.getUuid()) {
+ if (this.state != State.FLYING && !this.world.isClient && (this.state == State.BOBBING || this.isNoClip()) && this.shake <= 0) {
+ boolean bl = this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED || this.pickupType == PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY && player.getAbilities().creativeMode || this.isNoClip() && this.getOwner().getUuid() == player.getUuid();
+ if (this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED && !player.getInventory().insertStack(this.asItemStack())) {
+ bl = false;
+ }
+
+ if (bl) {
+ player.sendPickup(this, 1);
+ this.discard();
+ }
+ } else {
+ super.onPlayerCollision(player);
+ }
+ }
+ }
+
+ @Override
+ public void readCustomDataFromNbt(NbtCompound tag) {
+ super.readCustomDataFromNbt(tag);
+ if (tag.contains("Trident", 10)) {
+ this.harpoonStack = ItemStack.fromNbt(tag.getCompound("Harpoon"));
+ }
+
+ this.dealtDamage = tag.getBoolean("DealtDamage");
+ }
+
+ @Override
+ public void writeCustomDataToNbt(NbtCompound tag) {
+ super.writeCustomDataToNbt(tag);
+ tag.put("Harpoon", this.harpoonStack.writeNbt(new NbtCompound()));
+ tag.putBoolean("DealtDamage", this.dealtDamage);
+ }
+
+ @Override
+ public void age() {
+ if (this.pickupType != PersistentProjectileEntity.PickupPermission.ALLOWED) {
+ super.age();
+ }
+ }
+
+ @Override
+ protected float getDragInWater() {
+ return 0.9F;
+ }
+
+ @Override
+ public boolean shouldRender(double cameraX, double cameraY, double cameraZ) {
+ return true;
+ }
+
+ enum State {
+ FLYING,
+ HOOKED_IN_ENTITY,
+ BOBBING,
+ LANDED
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java
index ae6925bf..0792358f 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java
@@ -1,11 +1,16 @@
package com.github.platymemo.alaskanativecraft.entity;
+import java.util.EnumSet;
+
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.entity.ai.goal.AdultMeleeAttackGoal;
import com.github.platymemo.alaskanativecraft.entity.ai.goal.ChildEscapeDangerGoal;
import com.github.platymemo.alaskanativecraft.mixin.AxeItemAccessor;
import com.github.platymemo.alaskanativecraft.sound.AlaskaSoundEvents;
import com.github.platymemo.alaskanativecraft.tags.common.CommonBlockTags;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PillarBlock;
@@ -13,7 +18,15 @@
import net.minecraft.entity.EntityPose;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.NavigationConditions;
-import net.minecraft.entity.ai.goal.*;
+import net.minecraft.entity.ai.goal.AnimalMateGoal;
+import net.minecraft.entity.ai.goal.FollowParentGoal;
+import net.minecraft.entity.ai.goal.Goal;
+import net.minecraft.entity.ai.goal.LookAroundGoal;
+import net.minecraft.entity.ai.goal.LookAtEntityGoal;
+import net.minecraft.entity.ai.goal.RevengeGoal;
+import net.minecraft.entity.ai.goal.SwimGoal;
+import net.minecraft.entity.ai.goal.TemptGoal;
+import net.minecraft.entity.ai.goal.WanderAroundFarGoal;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
@@ -29,186 +42,182 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.EnumSet;
public class MooseEntity extends AnimalEntity {
-
- protected MooseEntity(EntityType extends AnimalEntity> entityType, World world) {
- super(entityType, world);
- this.calculateDimensions();
- this.stepHeight = this.isBaby() ? 1.0F : 2.0F;
- }
-
- public static DefaultAttributeContainer.Builder createMooseAttributes() {
- return MooseEntity.createMobAttributes()
- .add(EntityAttributes.GENERIC_MAX_HEALTH, 20.0D)
- .add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 0.5D)
- .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2D)
- .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 8.0D)
- .add(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, 1.0D);
- }
-
- @Override
- protected void initGoals() {
- this.goalSelector.add(0, new SwimGoal(this));
- this.goalSelector.add(1, new ChildEscapeDangerGoal(this, 2.5D));
- this.goalSelector.add(1, new AdultMeleeAttackGoal(this, 2.5D, true));
- this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D));
- this.goalSelector.add(3, new TemptGoal(this, 1.25D, Ingredient.ofItems(Items.WHEAT), false));
- this.goalSelector.add(4, new FollowParentGoal(this, 1.25D));
- this.goalSelector.add(5, new WanderAroundFarGoal(this, 1.0D));
- this.goalSelector.add(6, new MooseEntity.EatBarkGoal(2.25D, 0.2D));
- this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F));
- this.goalSelector.add(7, new LookAroundGoal(this));
- this.targetSelector.add(0, new RevengeGoal(this).setGroupRevenge());
- }
-
- @Override
- protected SoundEvent getAmbientSound() {
- return this.random.nextInt(100) > 75 ? AlaskaSoundEvents.ENTITY_MOOSE_AMBIENT : super.getAmbientSound();
- }
-
- @Override
- protected SoundEvent getHurtSound(DamageSource source) {
- return AlaskaSoundEvents.ENTITY_MOOSE_HURT;
- }
-
- @Override
- protected SoundEvent getDeathSound() {
- return AlaskaSoundEvents.ENTITY_MOOSE_HURT;
- }
-
- @Override
- protected void playStepSound(BlockPos pos, BlockState state) {
- this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F);
- }
-
- @Override
- protected float getSoundVolume() {
- return 0.2F;
- }
-
- @Override
- public MooseEntity createChild(ServerWorld serverWorld, PassiveEntity passiveEntity) {
- return AlaskaEntities.MOOSE.create(serverWorld);
- }
-
- @Override
- protected void onGrowUp() {
- super.onGrowUp();
- this.stepHeight = 2.0F;
- }
-
- @Override
- protected float getActiveEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) {
- return dimensions.height * 0.95F;
- }
-
- class EatBarkGoal extends Goal {
- private final double distance;
- private final double speed;
- protected BlockPos logPos;
- protected BlockState logState;
- protected boolean logValid;
- private Vec3d target;
-
- public EatBarkGoal(double distance, double speed) {
- this.logPos = BlockPos.ORIGIN;
- this.distance = distance;
- this.speed = speed;
- this.setControls(EnumSet.of(Goal.Control.MOVE, Goal.Control.LOOK, Goal.Control.JUMP));
- }
-
- protected void setLogStripped() {
- World world = MooseEntity.this.world;
- if (this.logValid) {
- this.logState = world.getBlockState(this.logPos);
- if (this.logState.isIn(CommonBlockTags.LOGS_WITH_BARK)) {
- BlockState blockState = world.getBlockState(this.logPos);
- Block block = AxeItemAccessor.getStrippedBlocks().get(blockState.getBlock());
- if (block != null && !world.isClient) {
- world.setBlockState(this.logPos, block.getDefaultState().with(PillarBlock.AXIS, blockState.get(PillarBlock.AXIS)), 11);
- }
- }
- }
- }
-
- protected boolean targetLogPos() {
- Vec3d vec3d = this.locateLogPos();
- if (vec3d == null) {
- this.logValid = false;
- this.target = Vec3d.ZERO;
- this.logPos = BlockPos.ORIGIN;
- return false;
- } else {
- this.logValid = true;
- this.target = vec3d;
- this.logPos = new BlockPos(vec3d);
- return true;
- }
- }
-
- @Nullable
- protected Vec3d locateLogPos() {
- Iterable iterable = BlockPos.iterate(
- MooseEntity.this.getBlockX() - 3,
- MooseEntity.this.getBlockY() - 1,
- MooseEntity.this.getBlockZ() - 3,
- MooseEntity.this.getBlockX() + 3,
- MooseEntity.this.getBlockY() + 4,
- MooseEntity.this.getBlockZ() + 3
- );
-
- for (BlockPos blockPos : iterable) {
- if (MooseEntity.this.world.getBlockState(blockPos).isIn(CommonBlockTags.LOGS_WITH_BARK)) {
- return Vec3d.ofBottomCenter(blockPos);
- }
- }
- return null;
- }
-
- @Override
- public boolean canStart() {
- if (!AlaskaConfig.getConfig().mooseEatBark) {
- return false;
- }
-
- if (!MooseEntity.this.world.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)
- || !NavigationConditions.hasMobNavigation(MooseEntity.this)
- || MooseEntity.this.getTarget() != null
- || MooseEntity.this.isBaby()
- || MooseEntity.this.getRandom().nextInt(200) != 0) {
- return false;
- } else {
- return this.targetLogPos();
- }
- }
-
- @Override
- public boolean shouldContinue() {
- return !MooseEntity.this.getNavigation().isIdle();
- }
-
- @Override
- public void start() {
- MooseEntity.this.getNavigation().startMovingTo(this.target.x, this.target.y, this.target.z, this.speed);
- }
-
- @Override
- public void tick() {
- double h = MooseEntity.this.getPos().distanceTo(this.target);
- if (h < this.distance) {
- MooseEntity.this.getLookControl().lookAt(this.target);
- }
- }
-
- @Override
- public void stop() {
- this.setLogStripped();
- MooseEntity.this.getNavigation().stop();
- }
- }
+ protected MooseEntity(EntityType extends AnimalEntity> entityType, World world) {
+ super(entityType, world);
+ this.calculateDimensions();
+ this.stepHeight = this.isBaby() ? 1.0F : 2.0F;
+ }
+
+ public static DefaultAttributeContainer.Builder createMooseAttributes() {
+ return MooseEntity.createMobAttributes()
+ .add(EntityAttributes.GENERIC_MAX_HEALTH, 20.0D)
+ .add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 0.5D)
+ .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2D)
+ .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 8.0D)
+ .add(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, 1.0D);
+ }
+
+ @Override
+ protected void initGoals() {
+ this.goalSelector.add(0, new SwimGoal(this));
+ this.goalSelector.add(1, new ChildEscapeDangerGoal(this, 2.5D));
+ this.goalSelector.add(1, new AdultMeleeAttackGoal(this, 2.5D, true));
+ this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D));
+ this.goalSelector.add(3, new TemptGoal(this, 1.25D, Ingredient.ofItems(Items.WHEAT), false));
+ this.goalSelector.add(4, new FollowParentGoal(this, 1.25D));
+ this.goalSelector.add(5, new WanderAroundFarGoal(this, 1.0D));
+ this.goalSelector.add(6, new MooseEntity.EatBarkGoal(2.25D, 0.2D));
+ this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F));
+ this.goalSelector.add(7, new LookAroundGoal(this));
+ this.targetSelector.add(0, new RevengeGoal(this).setGroupRevenge());
+ }
+
+ @Override
+ protected SoundEvent getAmbientSound() {
+ return this.random.nextInt(100) > 75 ? AlaskaSoundEvents.ENTITY_MOOSE_AMBIENT : super.getAmbientSound();
+ }
+
+ @Override
+ protected SoundEvent getHurtSound(DamageSource source) {
+ return AlaskaSoundEvents.ENTITY_MOOSE_HURT;
+ }
+
+ @Override
+ protected SoundEvent getDeathSound() {
+ return AlaskaSoundEvents.ENTITY_MOOSE_HURT;
+ }
+
+ @Override
+ protected void playStepSound(BlockPos pos, BlockState state) {
+ this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F);
+ }
+
+ @Override
+ protected float getSoundVolume() {
+ return 0.2F;
+ }
+
+ @Override
+ public MooseEntity createChild(ServerWorld serverWorld, PassiveEntity passiveEntity) {
+ return AlaskaEntities.MOOSE.create(serverWorld);
+ }
+
+ @Override
+ protected void onGrowUp() {
+ super.onGrowUp();
+ this.stepHeight = 2.0F;
+ }
+
+ @Override
+ protected float getActiveEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) {
+ return dimensions.height * 0.95F;
+ }
+
+ class EatBarkGoal extends Goal {
+ private final double distance;
+ private final double speed;
+ protected BlockPos logPos;
+ protected BlockState logState;
+ protected boolean logValid;
+ private Vec3d target;
+
+ EatBarkGoal(double distance, double speed) {
+ this.logPos = BlockPos.ORIGIN;
+ this.distance = distance;
+ this.speed = speed;
+ this.setControls(EnumSet.of(Goal.Control.MOVE, Goal.Control.LOOK, Goal.Control.JUMP));
+ }
+
+ protected void setLogStripped() {
+ World world = MooseEntity.this.world;
+ if (this.logValid) {
+ this.logState = world.getBlockState(this.logPos);
+ if (this.logState.isIn(CommonBlockTags.LOGS_WITH_BARK)) {
+ BlockState blockState = world.getBlockState(this.logPos);
+ Block block = AxeItemAccessor.getStrippedBlocks().get(blockState.getBlock());
+ if (block != null && !world.isClient) {
+ world.setBlockState(this.logPos, block.getDefaultState().with(PillarBlock.AXIS, blockState.get(PillarBlock.AXIS)), 11);
+ }
+ }
+ }
+ }
+
+ protected boolean targetLogPos() {
+ Vec3d vec3d = this.locateLogPos();
+ if (vec3d == null) {
+ this.logValid = false;
+ this.target = Vec3d.ZERO;
+ this.logPos = BlockPos.ORIGIN;
+ return false;
+ } else {
+ this.logValid = true;
+ this.target = vec3d;
+ this.logPos = new BlockPos(vec3d);
+ return true;
+ }
+ }
+
+ @Nullable
+ protected Vec3d locateLogPos() {
+ Iterable iterable = BlockPos.iterate(
+ MooseEntity.this.getBlockX() - 3,
+ MooseEntity.this.getBlockY() - 1,
+ MooseEntity.this.getBlockZ() - 3,
+ MooseEntity.this.getBlockX() + 3,
+ MooseEntity.this.getBlockY() + 4,
+ MooseEntity.this.getBlockZ() + 3
+ );
+
+ for (BlockPos blockPos : iterable) {
+ if (MooseEntity.this.world.getBlockState(blockPos).isIn(CommonBlockTags.LOGS_WITH_BARK)) {
+ return Vec3d.ofBottomCenter(blockPos);
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean canStart() {
+ if (!AlaskaConfig.getConfig().mooseEatBark) {
+ return false;
+ }
+
+ if (!MooseEntity.this.world.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)
+ || !NavigationConditions.hasMobNavigation(MooseEntity.this)
+ || MooseEntity.this.getTarget() != null
+ || MooseEntity.this.isBaby()
+ || MooseEntity.this.getRandom().nextInt(200) != 0) {
+ return false;
+ } else {
+ return this.targetLogPos();
+ }
+ }
+
+ @Override
+ public boolean shouldContinue() {
+ return !MooseEntity.this.getNavigation().isIdle();
+ }
+
+ @Override
+ public void start() {
+ MooseEntity.this.getNavigation().startMovingTo(this.target.x, this.target.y, this.target.z, this.speed);
+ }
+
+ @Override
+ public void tick() {
+ double h = MooseEntity.this.getPos().distanceTo(this.target);
+ if (h < this.distance) {
+ MooseEntity.this.getLookControl().lookAt(this.target);
+ }
+ }
+
+ @Override
+ public void stop() {
+ this.setLogStripped();
+ MooseEntity.this.getNavigation().stop();
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java
index e511067f..026c2bef 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java
@@ -1,6 +1,8 @@
package com.github.platymemo.alaskanativecraft.entity;
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityData;
@@ -19,102 +21,103 @@
import net.minecraft.sound.SoundEvents;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.random.Random;
+import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.World;
-import net.minecraft.world.WorldAccess;
-import org.jetbrains.annotations.NotNull;
public class PtarmiganEntity extends ParrotEntity {
- private static final TrackedData TYPE;
-
- static {
- TYPE = DataTracker.registerData(PtarmiganEntity.class, TrackedDataHandlerRegistry.INTEGER);
- }
-
- public PtarmiganEntity(EntityType extends ParrotEntity> entityType, World world) {
- super(entityType, world);
- }
-
- public static boolean isValidSpawn(EntityType type, @NotNull WorldAccess world, SpawnReason spawnReason, @NotNull BlockPos pos, Random random) {
- BlockState blockState = world.getBlockState(pos.down());
- return (blockState.isIn(BlockTags.LEAVES) || blockState.isOf(Blocks.GRASS_BLOCK) || blockState.isIn(BlockTags.LOGS) || blockState.isOf(Blocks.AIR)) && world.getBaseLightLevel(pos, 0) > 8;
- }
-
- public static DefaultAttributeContainer.Builder createPtarmiganAttributes() {
- return PtarmiganEntity.createMobAttributes().
- add(EntityAttributes.GENERIC_MAX_HEALTH, 6.0D).
- add(EntityAttributes.GENERIC_FLYING_SPEED, 0.4000000059604645D).
- add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.20000000298023224D);
- }
-
- @Override
- public EntityData initialize(@NotNull ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag) {
- if (world.getBiome(getBlockPos()).isIn(ConventionalBiomeTags.SNOWY) || world.getBiome(getBlockPos()).isIn(ConventionalBiomeTags.CLIMATE_COLD)) {
- this.setType(0);
- } else {
- this.setType(this.random.nextInt(2) + 1);
- }
- if (entityData == null) {
- entityData = new PassiveEntity.PassiveData(false);
- }
-
- return super.initialize(world, difficulty, spawnReason, entityData, entityTag);
- }
-
- @Override
- public PtarmiganEntity createChild(ServerWorld world, PassiveEntity entity) {
- PtarmiganEntity ptarmiganEntity = AlaskaEntities.PTARMIGAN.create(world);
- if (ptarmiganEntity != null)
- ptarmiganEntity.setType(this.random.nextBoolean() ? this.getPtarmiganType() : ((PtarmiganEntity) entity).getPtarmiganType());
- return ptarmiganEntity;
- }
-
- @Override
- protected void initDataTracker() {
- super.initDataTracker();
- this.dataTracker.startTracking(TYPE, 0);
- }
-
- @Override
- public SoundEvent getAmbientSound() {
- return SoundEvents.ENTITY_PARROT_AMBIENT;
- }
-
- /**
- * This is so the Ptarmigan doesn't imitate mobs as parrots do
- */
- @Override
- public void tickMovement() {
- boolean silent = this.isSilent();
- this.setSilent(true);
- super.tickMovement();
- this.setSilent(silent);
- }
-
- public int getPtarmiganType() {
- return this.dataTracker.get(TYPE);
- }
-
- /*
- * Somehow a player spawned a ptarmigan with type = 3, so this is a safety check
- */
- private void setType(int type) {
- if (type >= 0 && type < 3) {
- this.dataTracker.set(TYPE, type);
- }
- }
-
- @Override
- public void writeCustomDataToNbt(NbtCompound tag) {
- super.writeCustomDataToNbt(tag);
- tag.putInt("Type", this.getPtarmiganType());
- }
-
- @Override
- public void readCustomDataFromNbt(NbtCompound tag) {
- super.readCustomDataFromNbt(tag);
- this.setType(tag.getInt("Type"));
- }
+ private static final TrackedData TYPE;
+
+ static {
+ TYPE = DataTracker.registerData(PtarmiganEntity.class, TrackedDataHandlerRegistry.INTEGER);
+ }
+
+ public PtarmiganEntity(EntityType extends ParrotEntity> entityType, World world) {
+ super(entityType, world);
+ }
+
+ public static boolean isValidSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) {
+ BlockState blockState = serverWorldAccess.getBlockState(blockPos.down());
+ return (blockState.isIn(BlockTags.LEAVES) || blockState.isOf(Blocks.GRASS_BLOCK) || blockState.isIn(BlockTags.LOGS) || blockState.isOf(Blocks.AIR)) && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8;
+ }
+
+ public static DefaultAttributeContainer.Builder createPtarmiganAttributes() {
+ return PtarmiganEntity.createMobAttributes()
+ .add(EntityAttributes.GENERIC_MAX_HEALTH, 6.0D)
+ .add(EntityAttributes.GENERIC_FLYING_SPEED, 0.4000000059604645D)
+ .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.20000000298023224D);
+ }
+
+ @Override
+ public EntityData initialize(@NotNull ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag) {
+ if (world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.SNOWY) || world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.CLIMATE_COLD)) {
+ this.setType(0);
+ } else {
+ this.setType(this.random.nextInt(2) + 1);
+ }
+
+ if (entityData == null) {
+ entityData = new PassiveEntity.PassiveData(false);
+ }
+
+ return super.initialize(world, difficulty, spawnReason, entityData, entityTag);
+ }
+
+ @Override
+ public PtarmiganEntity createChild(ServerWorld world, PassiveEntity entity) {
+ PtarmiganEntity ptarmiganEntity = AlaskaEntities.PTARMIGAN.create(world);
+ if (ptarmiganEntity != null) {
+ ptarmiganEntity.setType(this.random.nextBoolean() ? this.getPtarmiganType() : ((PtarmiganEntity) entity).getPtarmiganType());
+ }
+
+ return ptarmiganEntity;
+ }
+
+ @Override
+ protected void initDataTracker() {
+ super.initDataTracker();
+ this.dataTracker.startTracking(TYPE, 0);
+ }
+
+ @Override
+ public SoundEvent getAmbientSound() {
+ return SoundEvents.ENTITY_PARROT_AMBIENT;
+ }
+
+ /**
+ * This is so the Ptarmigan doesn't imitate mobs as parrots do.
+ */
+ @Override
+ public void tickMovement() {
+ boolean silent = this.isSilent();
+ this.setSilent(true);
+ super.tickMovement();
+ this.setSilent(silent);
+ }
+
+ public int getPtarmiganType() {
+ return this.dataTracker.get(TYPE);
+ }
+
+ /*
+ * Somehow a player spawned a ptarmigan with type = 3, so this is a safety check
+ */
+ private void setType(int type) {
+ if (type >= 0 && type < 3) {
+ this.dataTracker.set(TYPE, type);
+ }
+ }
+
+ @Override
+ public void writeCustomDataToNbt(NbtCompound tag) {
+ super.writeCustomDataToNbt(tag);
+ tag.putInt("Type", this.getPtarmiganType());
+ }
+
+ @Override
+ public void readCustomDataFromNbt(NbtCompound tag) {
+ super.readCustomDataFromNbt(tag);
+ this.setType(tag.getInt("Type"));
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java
index 14738824..810e11fc 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java
@@ -4,17 +4,41 @@
import com.github.platymemo.alaskanativecraft.entity.ai.goal.GroundFoodMateGoal;
import com.github.platymemo.alaskanativecraft.sound.AlaskaSoundEvents;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
-import net.minecraft.entity.*;
-import net.minecraft.entity.ai.TargetPredicate;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityData;
+import net.minecraft.entity.EntityGroup;
+import net.minecraft.entity.EntityType;
+import net.minecraft.entity.MovementType;
+import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.ai.control.MoveControl;
-import net.minecraft.entity.ai.goal.*;
-import net.minecraft.entity.ai.pathing.*;
+import net.minecraft.entity.ai.goal.AnimalMateGoal;
+import net.minecraft.entity.ai.goal.EscapeDangerGoal;
+import net.minecraft.entity.ai.goal.FleeEntityGoal;
+import net.minecraft.entity.ai.goal.LookAtEntityGoal;
+import net.minecraft.entity.ai.goal.MeleeAttackGoal;
+import net.minecraft.entity.ai.goal.SwimAroundGoal;
+import net.minecraft.entity.ai.goal.TargetGoal;
+import net.minecraft.entity.ai.goal.TemptGoal;
+import net.minecraft.entity.ai.goal.WanderAroundGoal;
+import net.minecraft.entity.ai.pathing.AmphibiousPathNodeMaker;
+import net.minecraft.entity.ai.pathing.EntityNavigation;
+import net.minecraft.entity.ai.pathing.PathNodeNavigator;
+import net.minecraft.entity.ai.pathing.PathNodeType;
+import net.minecraft.entity.ai.pathing.SwimNavigation;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
-import net.minecraft.entity.passive.*;
+import net.minecraft.entity.passive.AnimalEntity;
+import net.minecraft.entity.passive.CodEntity;
+import net.minecraft.entity.passive.PassiveEntity;
+import net.minecraft.entity.passive.PolarBearEntity;
+import net.minecraft.entity.passive.SalmonEntity;
+import net.minecraft.entity.passive.SquidEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
@@ -26,359 +50,295 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
-import net.minecraft.util.math.random.Random;
+import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.EnumSet;
public class SealEntity extends AnimalEntity {
-
- public SealEntity(EntityType extends SealEntity> entityType, World world) {
- super(entityType, world);
- this.setPathfindingPenalty(PathNodeType.WATER, 0.0F);
- this.moveControl = new SealEntity.SealMoveControl(this);
- this.stepHeight = 1.0F;
- }
-
- @SuppressWarnings({"deprecation", "unused"})
- public static boolean canSpawn(EntityType type, @NotNull ServerWorldAccess world, SpawnReason spawnReason, @NotNull BlockPos pos, Random random) {
- return pos.getY() < world.getSeaLevel() + 2 && pos.getY() > world.getSeaLevel() - 10 && world.getBaseLightLevel(pos, 0) > 8;
- }
-
- public static DefaultAttributeContainer.Builder createSealAttributes() {
- return SealEntity.createMobAttributes().
- add(EntityAttributes.GENERIC_MAX_HEALTH, 10.0D).
- add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75D).
- add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 1.5D);
- }
-
- @Override
- public boolean canSpawn(WorldView world) {
- return world.doesNotIntersectEntities(this);
- }
-
- @Override
- @Nullable
- public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData, @Nullable NbtCompound entityTag) {
- return super.initialize(world, difficulty, spawnReason, entityData, entityTag);
- }
-
- @Override
- protected void initGoals() {
- this.goalSelector.add(0, new FleeEntityGoal<>(this, PolarBearEntity.class, 8.0F, 1.0D, 1.5D));
- this.goalSelector.add(0, new SealEntity.SealEscapeDangerGoal(this, 1.5D));
- this.goalSelector.add(1, new AnimalMateGoal(this, 1.0D));
- this.goalSelector.add(2, new SealEntity.ApproachFoodHoldingPlayerGoal(this, 1.1D, Ingredient.fromTag(AlaskaTags.SEAL_FOOD)));
- this.goalSelector.add(3, new FleeEntityGoal<>(this, PlayerEntity.class, 16.0F, 1.0D, 1.5D));
- this.goalSelector.add(3, new SwimAroundGoal(this, this.isBaby() ? 2.0D : 1.0D, 40));
- this.goalSelector.add(5, new SealEntity.WanderOnLandGoal(this, 1.0D, 100));
- this.goalSelector.add(5, new GroundFoodMateGoal(this));
- this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F));
- this.goalSelector.add(7, new SealEntity.HuntFishGoal(this, 1.2D, true));
- this.targetSelector.add(0, new ActiveTargetGoal<>(this, SalmonEntity.class, true));
- this.targetSelector.add(0, new ActiveTargetGoal<>(this, CodEntity.class, true));
- this.targetSelector.add(1, new ActiveTargetGoal<>(this, SquidEntity.class, true));
- }
-
- @Override
- public boolean isPushedByFluids() {
- return false;
- }
-
- @Override
- public boolean canBreatheInWater() {
- return true;
- }
-
- @Override
- public EntityGroup getGroup() {
- return EntityGroup.AQUATIC;
- }
-
- @Override
- public int getMinAmbientSoundDelay() {
- return 200;
- }
-
- @Override
- @Nullable
- protected SoundEvent getAmbientSound() {
- if (!this.isTouchingWater() && this.onGround) {
- return this.isBaby() ? AlaskaSoundEvents.ENTITY_SEAL_AMBIENT_BABY : AlaskaSoundEvents.ENTITY_SEAL_AMBIENT;
- }
- return super.getAmbientSound();
- }
-
- @Override
- protected void playSwimSound(float volume) {
- super.playSwimSound(volume * 1.5F);
- }
-
- @Override
- protected SoundEvent getSwimSound() {
- return SoundEvents.ENTITY_TURTLE_SWIM;
- }
-
- @Override
- @Nullable
- protected SoundEvent getHurtSound(DamageSource source) {
- return AlaskaSoundEvents.ENTITY_SEAL_HURT;
- }
-
- @Override
- @Nullable
- protected SoundEvent getDeathSound() {
- return AlaskaSoundEvents.ENTITY_SEAL_HURT;
- }
-
- @Override
- protected void playStepSound(BlockPos pos, BlockState state) {
- SoundEvent soundEvent = this.isBaby() ? SoundEvents.ENTITY_TURTLE_SHAMBLE_BABY : SoundEvents.ENTITY_TURTLE_SHAMBLE;
- this.playSound(soundEvent, 0.15F, 1.0F);
- }
-
- @Override
- protected float calculateNextStepSoundDistance() {
- return this.distanceTraveled + 0.15F;
- }
-
- @Override
- public float getScaleFactor() {
- return this.isBaby() ? 0.3F : 1.0F;
- }
-
- @Override
- protected EntityNavigation createNavigation(World world) {
- return new SealEntity.SealSwimNavigation(this, world);
- }
-
- @Override
- @Nullable
- public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) {
- return AlaskaEntities.HARP_SEAL.create(world);
- }
-
- @Override
- public boolean isBreedingItem(@NotNull ItemStack stack) {
- return stack.isIn(AlaskaTags.SEAL_FOOD);
- }
-
- @Override
- public float getPathfindingFavor(BlockPos pos, @NotNull WorldView world) {
- if (world.getFluidState(pos).isIn(FluidTags.WATER)) {
- return 15.0F;
- } else {
- return world.getBlockState(pos).isOf(Blocks.SAND) ? 10.0F : world.getLightLevel(pos) - 0.5F;
- }
- }
-
- @Override
- public void travel(Vec3d movementInput) {
- if (this.canMoveVoluntarily() && this.isTouchingWater()) {
- this.updateVelocity(0.1F, movementInput);
- this.move(MovementType.SELF, this.getVelocity());
- this.setVelocity(this.getVelocity().multiply(0.9D));
- if (this.getTarget() == null) {
- this.setVelocity(this.getVelocity().add(0.0D, -0.005D, 0.0D));
- }
- } else {
- super.travel(movementInput);
- }
- }
-
- @Override
- public boolean tryAttack(@NotNull Entity target) {
- boolean bl = target.damage(DamageSource.mob(this), (float) ((int) this.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE)));
- if (bl) {
- this.applyDamageEffects(this, target);
- }
-
- return bl;
- }
-
- static class SealSwimNavigation extends SwimNavigation {
- SealSwimNavigation(SealEntity owner, World world) {
- super(owner, world);
- }
-
- @Override
- protected boolean isAtValidPosition() {
- return true;
- }
-
- @Override
- protected PathNodeNavigator createPathNodeNavigator(int range) {
- this.nodeMaker = new AmphibiousPathNodeMaker(false);
- return new PathNodeNavigator(this.nodeMaker, range);
- }
-
- @Override
- public boolean isValidPosition(BlockPos pos) {
- return !this.world.getBlockState(pos.down()).isAir();
- }
- }
-
- static class SealMoveControl extends MoveControl {
- private final SealEntity seal;
-
- SealMoveControl(SealEntity seal) {
- super(seal);
- this.seal = seal;
- }
-
- private void updateVelocity() {
- if (this.seal.isTouchingWater()) {
- this.seal.setVelocity(this.seal.getVelocity().add(0.0D, 0.005D, 0.0D));
- this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.1F));
-
- if (this.seal.isBaby()) {
- this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 2.0F, 0.08F));
- }
-
- } else if (this.seal.onGround) {
- this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.08F));
- }
-
- }
-
- @Override
- public void tick() {
- this.updateVelocity();
- if (this.state == MoveControl.State.MOVE_TO && !this.seal.getNavigation().isIdle()) {
- double d = this.targetX - this.seal.getX();
- double e = this.targetY - this.seal.getY();
- double f = this.targetZ - this.seal.getZ();
- double g = Math.sqrt(d * d + e * e + f * f);
- e /= g;
- float h = (float) (MathHelper.atan2(f, d) * 57.2957763671875D) - 90.0F;
- this.seal.setYaw(this.wrapDegrees(this.seal.getYaw(), h, 90.0F));
- this.seal.bodyYaw = this.seal.getYaw();
- this.seal.headYaw = this.seal.getYaw();
- float i = (float) (this.speed * this.seal.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED));
- this.seal.setMovementSpeed(MathHelper.lerp(0.125F, this.seal.getMovementSpeed(), i));
- this.seal.setVelocity(this.seal.getVelocity().add(0.0D, (double) this.seal.getMovementSpeed() * e * 0.1D, 0.0D));
- } else {
- this.seal.setMovementSpeed(0.0F);
- }
- }
- }
-
- static class WanderOnLandGoal extends WanderAroundGoal {
-
- private WanderOnLandGoal(SealEntity seal, double speed, int chance) {
- super(seal, speed, chance);
- }
-
- @Override
- public boolean canStart() {
- return !this.mob.isTouchingWater() && super.canStart();
- }
- }
-
- static class ApproachFoodHoldingPlayerGoal extends Goal {
- private static final TargetPredicate CLOSE_ENTITY_PREDICATE = TargetPredicate.DEFAULT.setBaseMaxDistance(10.0D);
- private final SealEntity seal;
- private final double speed;
- private final Ingredient food;
- private PlayerEntity targetPlayer;
- private int cooldown;
-
- ApproachFoodHoldingPlayerGoal(SealEntity seal, double speed, Ingredient food) {
- this.seal = seal;
- this.speed = speed;
- this.food = food;
- this.setControls(EnumSet.of(Goal.Control.MOVE, Goal.Control.LOOK));
- }
-
- @Override
- public boolean canStart() {
- if (this.cooldown > 0) {
- --this.cooldown;
- return false;
- } else {
- this.targetPlayer = this.seal.world.getClosestPlayer(CLOSE_ENTITY_PREDICATE, this.seal);
- if (this.targetPlayer == null) {
- return false;
- } else {
- return this.isAttractive(this.targetPlayer.getMainHandStack()) || this.isAttractive(this.targetPlayer.getOffHandStack());
- }
- }
- }
-
- private boolean isAttractive(ItemStack stack) {
- return this.food.test(stack);
- }
-
- @Override
- public boolean shouldContinue() {
- return this.canStart();
- }
-
- @Override
- public void stop() {
- this.targetPlayer = null;
- this.seal.getNavigation().stop();
- this.cooldown = 100;
- }
-
- @Override
- public void tick() {
- this.seal.getLookControl().lookAt(this.targetPlayer, (float) (this.seal.getMaxHeadRotation() + 20), (float) this.seal.getMaxLookPitchChange());
- if (this.seal.squaredDistanceTo(this.targetPlayer) < 6.25D) {
- this.seal.getNavigation().stop();
- } else {
- this.seal.getNavigation().startMovingTo(this.targetPlayer, this.speed);
- }
-
- }
- }
-
- static class HuntFishGoal extends MeleeAttackGoal {
- private final AnimalEntity animal;
-
- public HuntFishGoal(SealEntity sealEntity, double speed, boolean pauseWhenMobIdle) {
- super(sealEntity, speed, pauseWhenMobIdle);
- this.animal = sealEntity;
- }
-
- @Override
- public boolean canStart() {
- if (!AlaskaConfig.getConfig().sealFishing.sealsHuntFish) {
- return false;
- }
-
- if (this.animal.getRandom().nextInt(1000) != 0 || !this.animal.canEat()) {
- return false;
- }
- return super.canStart();
- }
- }
-
- static class SealEscapeDangerGoal extends EscapeDangerGoal {
- SealEscapeDangerGoal(SealEntity seal, double speed) {
- super(seal, speed);
- }
-
- @Override
- public boolean canStart() {
- if (this.mob.getAttacker() == null && !this.mob.isOnFire()) {
- return false;
- } else {
- BlockPos blockPos = this.locateClosestWater(this.mob.world, this.mob, 5);
- if (blockPos != null) {
- this.targetX = blockPos.getX();
- this.targetY = blockPos.getY();
- this.targetZ = blockPos.getZ();
- return true;
- } else {
- return this.findTarget();
- }
- }
- }
- }
+ public SealEntity(EntityType extends SealEntity> entityType, World world) {
+ super(entityType, world);
+ this.setPathfindingPenalty(PathNodeType.WATER, 0.0F);
+ this.moveControl = new SealEntity.SealMoveControl(this);
+ this.stepHeight = 1.0F;
+ }
+
+ @SuppressWarnings({"deprecation", "unused"})
+ public static boolean canSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) {
+ return blockPos.getY() < serverWorldAccess.getSeaLevel() + 2 && blockPos.getY() > serverWorldAccess.getSeaLevel() - 10 && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8;
+ }
+
+ public static DefaultAttributeContainer.Builder createSealAttributes() {
+ return SealEntity.createMobAttributes()
+ .add(EntityAttributes.GENERIC_MAX_HEALTH, 10.0D)
+ .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75D)
+ .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 1.5D);
+ }
+
+ @Override
+ public boolean canSpawn(WorldView world) {
+ return world.doesNotIntersectEntities(this);
+ }
+
+ @Override
+ @Nullable
+ public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData, @Nullable NbtCompound entityTag) {
+ return super.initialize(world, difficulty, spawnReason, entityData, entityTag);
+ }
+
+ @Override
+ protected void initGoals() {
+ this.goalSelector.add(0, new FleeEntityGoal<>(this, PolarBearEntity.class, 8.0F, 1.0D, 1.5D));
+ this.goalSelector.add(0, new SealEntity.SealEscapeDangerGoal(this, 1.5D));
+ this.goalSelector.add(1, new AnimalMateGoal(this, 1.0D));
+ this.goalSelector.add(2, new TemptGoal(this, 1.1D, Ingredient.ofTag(AlaskaTags.SEAL_FOOD), true));
+ this.goalSelector.add(3, new FleeEntityGoal<>(this, PlayerEntity.class, 16.0F, 1.0D, 1.5D));
+ this.goalSelector.add(3, new SwimAroundGoal(this, this.isBaby() ? 2.0D : 1.0D, 40));
+ this.goalSelector.add(5, new SealEntity.WanderOnLandGoal(this, 1.0D, 100));
+ this.goalSelector.add(5, new GroundFoodMateGoal(this));
+ this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F));
+ this.goalSelector.add(7, new SealEntity.HuntFishGoal(this, 1.2D, true));
+ this.targetSelector.add(0, new TargetGoal<>(this, SalmonEntity.class, true));
+ this.targetSelector.add(0, new TargetGoal<>(this, CodEntity.class, true));
+ this.targetSelector.add(1, new TargetGoal<>(this, SquidEntity.class, true));
+ }
+
+ @Override
+ public boolean isPushedByFluids() {
+ return false;
+ }
+
+ @Override
+ public boolean canBreatheInWater() {
+ return true;
+ }
+
+ @Override
+ public EntityGroup getGroup() {
+ return EntityGroup.AQUATIC;
+ }
+
+ @Override
+ public int getMinAmbientSoundDelay() {
+ return 200;
+ }
+
+ @Override
+ @Nullable
+ protected SoundEvent getAmbientSound() {
+ if (!this.isTouchingWater() && this.onGround) {
+ return this.isBaby() ? AlaskaSoundEvents.ENTITY_SEAL_AMBIENT_BABY : AlaskaSoundEvents.ENTITY_SEAL_AMBIENT;
+ }
+
+ return super.getAmbientSound();
+ }
+
+ @Override
+ protected void playSwimSound(float volume) {
+ super.playSwimSound(volume * 1.5F);
+ }
+
+ @Override
+ protected SoundEvent getSwimSound() {
+ return SoundEvents.ENTITY_TURTLE_SWIM;
+ }
+
+ @Override
+ @Nullable
+ protected SoundEvent getHurtSound(DamageSource source) {
+ return AlaskaSoundEvents.ENTITY_SEAL_HURT;
+ }
+
+ @Override
+ @Nullable
+ protected SoundEvent getDeathSound() {
+ return AlaskaSoundEvents.ENTITY_SEAL_HURT;
+ }
+
+ @Override
+ protected void playStepSound(BlockPos pos, BlockState state) {
+ SoundEvent soundEvent = this.isBaby() ? SoundEvents.ENTITY_TURTLE_SHAMBLE_BABY : SoundEvents.ENTITY_TURTLE_SHAMBLE;
+ this.playSound(soundEvent, 0.15F, 1.0F);
+ }
+
+ @Override
+ protected float calculateNextStepSoundDistance() {
+ return this.distanceTraveled + 0.15F;
+ }
+
+ @Override
+ public float getScaleFactor() {
+ return this.isBaby() ? 0.3F : 1.0F;
+ }
+
+ @Override
+ protected EntityNavigation createNavigation(World world) {
+ return new SealEntity.SealSwimNavigation(this, world);
+ }
+
+ @Override
+ @Nullable
+ public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) {
+ return AlaskaEntities.HARP_SEAL.create(world);
+ }
+
+ @Override
+ public boolean isBreedingItem(@NotNull ItemStack stack) {
+ return stack.isIn(AlaskaTags.SEAL_FOOD);
+ }
+
+ @Override
+ public float getPathfindingFavor(BlockPos pos, @NotNull WorldView world) {
+ if (world.getFluidState(pos).isIn(FluidTags.WATER)) {
+ return 15.0F;
+ } else {
+ return world.getBlockState(pos).isOf(Blocks.SAND) ? 10.0F : world.getLightLevel(pos) - 0.5F;
+ }
+ }
+
+ @Override
+ public void travel(Vec3d movementInput) {
+ if (this.canMoveVoluntarily() && this.isTouchingWater()) {
+ this.updateVelocity(0.1F, movementInput);
+ this.move(MovementType.SELF, this.getVelocity());
+ this.setVelocity(this.getVelocity().multiply(0.9D));
+ if (this.getTarget() == null) {
+ this.setVelocity(this.getVelocity().add(0.0D, -0.005D, 0.0D));
+ }
+ } else {
+ super.travel(movementInput);
+ }
+ }
+
+ @Override
+ public boolean tryAttack(@NotNull Entity target) {
+ boolean bl = target.damage(DamageSource.mob(this), (float) ((int) this.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE)));
+ if (bl) {
+ this.applyDamageEffects(this, target);
+ }
+
+ return bl;
+ }
+
+ static class SealSwimNavigation extends SwimNavigation {
+ SealSwimNavigation(SealEntity owner, World world) {
+ super(owner, world);
+ }
+
+ @Override
+ protected boolean isAtValidPosition() {
+ return true;
+ }
+
+ @Override
+ protected PathNodeNavigator createPathNodeNavigator(int range) {
+ this.nodeMaker = new AmphibiousPathNodeMaker(false);
+ return new PathNodeNavigator(this.nodeMaker, range);
+ }
+
+ @Override
+ public boolean isValidPosition(BlockPos pos) {
+ return !this.world.getBlockState(pos.down()).isAir();
+ }
+ }
+
+ static class SealMoveControl extends MoveControl {
+ private final SealEntity seal;
+
+ SealMoveControl(SealEntity seal) {
+ super(seal);
+ this.seal = seal;
+ }
+
+ private void updateVelocity() {
+ if (this.seal.isTouchingWater()) {
+ this.seal.setVelocity(this.seal.getVelocity().add(0.0D, 0.005D, 0.0D));
+ this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.1F));
+
+ if (this.seal.isBaby()) {
+ this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 2.0F, 0.08F));
+ }
+ } else if (this.seal.onGround) {
+ this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.08F));
+ }
+ }
+
+ @Override
+ public void tick() {
+ this.updateVelocity();
+ if (this.state == MoveControl.State.MOVE_TO && !this.seal.getNavigation().isIdle()) {
+ double d = this.targetX - this.seal.getX();
+ double e = this.targetY - this.seal.getY();
+ double f = this.targetZ - this.seal.getZ();
+ double g = Math.sqrt(d * d + e * e + f * f);
+ e /= g;
+ float h = (float) (MathHelper.atan2(f, d) * 57.2957763671875D) - 90.0F;
+ this.seal.setYaw(this.wrapDegrees(this.seal.getYaw(), h, 90.0F));
+ this.seal.bodyYaw = this.seal.getYaw();
+ this.seal.headYaw = this.seal.getYaw();
+ float i = (float) (this.speed * this.seal.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED));
+ this.seal.setMovementSpeed(MathHelper.lerp(0.125F, this.seal.getMovementSpeed(), i));
+ this.seal.setVelocity(this.seal.getVelocity().add(0.0D, (double) this.seal.getMovementSpeed() * e * 0.1D, 0.0D));
+ } else {
+ this.seal.setMovementSpeed(0.0F);
+ }
+ }
+ }
+
+ static class WanderOnLandGoal extends WanderAroundGoal {
+ private WanderOnLandGoal(SealEntity seal, double speed, int chance) {
+ super(seal, speed, chance);
+ }
+
+ @Override
+ public boolean canStart() {
+ return !this.mob.isTouchingWater() && super.canStart();
+ }
+ }
+
+ static class HuntFishGoal extends MeleeAttackGoal {
+ private final AnimalEntity animal;
+
+ HuntFishGoal(SealEntity sealEntity, double speed, boolean pauseWhenMobIdle) {
+ super(sealEntity, speed, pauseWhenMobIdle);
+ this.animal = sealEntity;
+ }
+
+ @Override
+ public boolean canStart() {
+ if (!AlaskaConfig.getConfig().sealFishing.sealsHuntFish) {
+ return false;
+ }
+
+ if (this.animal.getRandom().nextInt(1000) != 0 || !this.animal.canEat()) {
+ return false;
+ }
+
+ return super.canStart();
+ }
+ }
+
+ static class SealEscapeDangerGoal extends EscapeDangerGoal {
+ SealEscapeDangerGoal(SealEntity seal, double speed) {
+ super(seal, speed);
+ }
+
+ @Override
+ public boolean canStart() {
+ if (this.mob.getAttacker() == null && !this.mob.isOnFire()) {
+ return false;
+ } else {
+ BlockPos blockPos = this.locateClosestWater(this.mob.world, this.mob, 5);
+ if (blockPos != null) {
+ this.targetX = blockPos.getX();
+ this.targetY = blockPos.getY();
+ this.targetZ = blockPos.getZ();
+ return true;
+ } else {
+ return this.findTarget();
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java
index 7f37fdc1..09efe24f 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java
@@ -1,47 +1,47 @@
package com.github.platymemo.alaskanativecraft.entity.ai.goal;
import com.github.platymemo.alaskanativecraft.mixin.MeleeAttackGoalAccessor;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.entity.mob.PathAwareEntity;
import net.minecraft.util.Hand;
-import org.jetbrains.annotations.NotNull;
public class AdultMeleeAttackGoal extends MeleeAttackGoal {
+ public AdultMeleeAttackGoal(PathAwareEntity mob, double speed, boolean pauseWhenMobIdle) {
+ super(mob, speed, pauseWhenMobIdle);
+ }
- public AdultMeleeAttackGoal(PathAwareEntity mob, double speed, boolean pauseWhenMobIdle) {
- super(mob, speed, pauseWhenMobIdle);
- }
-
- @Override
- public boolean canStart() {
- if (!mob.isBaby()) {
- return super.canStart();
- } else {
- return false;
- }
- }
+ @Override
+ public boolean canStart() {
+ if (!mob.isBaby()) {
+ return super.canStart();
+ } else {
+ return false;
+ }
+ }
- @Override
- protected void resetCooldown() {
- ((MeleeAttackGoalAccessor) this).setCooldown(50);
- }
+ @Override
+ protected void resetCooldown() {
+ ((MeleeAttackGoalAccessor) this).setCooldown(50);
+ }
- @Override
- protected double getSquaredMaxAttackDistance(@NotNull LivingEntity entity) {
- float f = mob.getWidth() - 1.0F;
- return (f * 2.0F * f * 2.0F + entity.getWidth());
- }
+ @Override
+ protected double getSquaredMaxAttackDistance(@NotNull LivingEntity entity) {
+ float f = mob.getWidth() - 1.0F;
+ return (f * 2.0F * f * 2.0F + entity.getWidth());
+ }
- @Override
- protected void attack(LivingEntity target, double squaredDistance) {
- double d = this.getSquaredMaxAttackDistance(target);
- if (squaredDistance <= d && this.isCooledDown()) {
- this.resetCooldown();
- this.mob.swingHand(Hand.MAIN_HAND);
- if (this.mob.tryAttack(target) && this.mob.getRandom().nextFloat() < 0.6F) {
- this.stop();
- }
- }
- }
+ @Override
+ protected void attack(LivingEntity target, double squaredDistance) {
+ double d = this.getSquaredMaxAttackDistance(target);
+ if (squaredDistance <= d && this.isCooledDown()) {
+ this.resetCooldown();
+ this.mob.swingHand(Hand.MAIN_HAND);
+ if (this.mob.tryAttack(target) && this.mob.getRandom().nextFloat() < 0.6F) {
+ this.stop();
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java
index a27c358f..86ae734b 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java
@@ -4,17 +4,16 @@
import net.minecraft.entity.mob.PathAwareEntity;
public class ChildEscapeDangerGoal extends EscapeDangerGoal {
+ public ChildEscapeDangerGoal(PathAwareEntity mob, double speed) {
+ super(mob, speed);
+ }
- public ChildEscapeDangerGoal(PathAwareEntity mob, double speed) {
- super(mob, speed);
- }
-
- @Override
- public boolean canStart() {
- if (mob.isBaby()) {
- return super.canStart();
- } else {
- return false;
- }
- }
+ @Override
+ public boolean canStart() {
+ if (mob.isBaby()) {
+ return super.canStart();
+ } else {
+ return false;
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java
index 2a17ad76..744b39a8 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java
@@ -5,86 +5,87 @@
package com.github.platymemo.alaskanativecraft.entity.ai.goal;
+import java.util.EnumSet;
+import java.util.List;
+
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.entity.SealEntity;
+
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.ai.goal.Goal;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.world.GameRules;
-import java.util.EnumSet;
-import java.util.List;
-
public class GroundFoodMateGoal extends Goal {
- protected final AnimalEntity animal;
- protected ItemEntity foodEntity;
-
- public GroundFoodMateGoal(AnimalEntity animal) {
- this.setControls(EnumSet.of(Control.MOVE, Control.LOOK));
- this.animal = animal;
- }
-
- @Override
- public boolean canStart() {
- if (this.animal instanceof SealEntity && !AlaskaConfig.getConfig().sealFishing.sealsEatHuntedFish) {
- return false;
- }
-
- if (this.animal.getEntityWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) {
- this.foodEntity = this.findFood();
- }
-
- if (this.animal.getRandom().nextInt(100) != 0) {
- return false;
- }
-
- return this.foodEntity != null;
- }
-
- @Override
- public boolean shouldContinue() {
- return this.foodEntity != null && this.foodEntity.getStack().getCount() > 0 && this.animal.canEat() && this.animal.getBreedingAge() == 0;
- }
-
- @Override
- public void stop() {
- this.foodEntity = null;
- }
-
- @Override
- public void tick() {
- if (this.foodEntity != null) {
- this.animal.getLookControl().lookAt(this.foodEntity, 10.0F, (float) this.animal.getMaxLookPitchChange());
- this.animal.getNavigation().startMovingTo(this.foodEntity, 1.0f);
- if (this.animal.squaredDistanceTo(this.foodEntity) < 4.0D) {
- this.feed();
- }
- }
- }
-
- private ItemEntity findFood() {
- List list = animal.world.getEntitiesByClass(ItemEntity.class, this.animal.getBoundingBox().expand(8.0D), (entity) -> true);
- double d = Double.MAX_VALUE;
-
- ItemEntity result = null;
- for (ItemEntity itemEntity : list) {
- if (this.animal.isBreedingItem(itemEntity.getStack()) && this.animal.squaredDistanceTo(itemEntity) < d) {
- result = itemEntity;
- d = this.animal.squaredDistanceTo(itemEntity);
- }
- }
-
- return result;
- }
-
- private void feed() {
- if (this.foodEntity.getStack().getCount() > 0) {
- foodEntity.getStack().decrement(1);
- if (!(this.animal instanceof SealEntity) || AlaskaConfig.getConfig().sealFishing.sealsBreedFromHuntedFish) {
- animal.lovePlayer(null);
- }
- }
-
- stop();
- }
+ protected final AnimalEntity animal;
+ protected ItemEntity foodEntity;
+
+ public GroundFoodMateGoal(AnimalEntity animal) {
+ this.setControls(EnumSet.of(Control.MOVE, Control.LOOK));
+ this.animal = animal;
+ }
+
+ @Override
+ public boolean canStart() {
+ if (this.animal instanceof SealEntity && !AlaskaConfig.getConfig().sealFishing.sealsEatHuntedFish) {
+ return false;
+ }
+
+ if (this.animal.getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) {
+ this.foodEntity = this.findFood();
+ }
+
+ if (this.animal.getRandom().nextInt(100) != 0) {
+ return false;
+ }
+
+ return this.foodEntity != null;
+ }
+
+ @Override
+ public boolean shouldContinue() {
+ return this.foodEntity != null && this.foodEntity.getStack().getCount() > 0 && this.animal.canEat() && this.animal.getBreedingAge() == 0;
+ }
+
+ @Override
+ public void stop() {
+ this.foodEntity = null;
+ }
+
+ @Override
+ public void tick() {
+ if (this.foodEntity != null) {
+ this.animal.getLookControl().lookAt(this.foodEntity, 10.0F, this.animal.getLookPitchSpeed());
+ this.animal.getNavigation().startMovingTo(this.foodEntity, 1.0f);
+ if (this.animal.squaredDistanceTo(this.foodEntity) < 4.0D) {
+ this.feed();
+ }
+ }
+ }
+
+ private ItemEntity findFood() {
+ List list = this.animal.world.getEntitiesByClass(ItemEntity.class, this.animal.getBoundingBox().expand(8.0D), (entity) -> true);
+ double d = Double.MAX_VALUE;
+
+ ItemEntity result = null;
+ for (ItemEntity itemEntity : list) {
+ if (this.animal.isBreedingItem(itemEntity.getStack()) && this.animal.squaredDistanceTo(itemEntity) < d) {
+ result = itemEntity;
+ d = this.animal.squaredDistanceTo(itemEntity);
+ }
+ }
+
+ return result;
+ }
+
+ private void feed() {
+ if (this.foodEntity.getStack().getCount() > 0) {
+ this.foodEntity.getStack().decrement(1);
+ if (!(this.animal instanceof SealEntity) || AlaskaConfig.getConfig().sealFishing.sealsBreedFromHuntedFish) {
+ this.animal.lovePlayer(null);
+ }
+ }
+
+ this.stop();
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java
index 28ca0069..b841bbe1 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java
@@ -1,14 +1,14 @@
package com.github.platymemo.alaskanativecraft.entity.effect;
import net.minecraft.entity.effect.StatusEffect;
-import net.minecraft.entity.effect.StatusEffectCategory;
+import net.minecraft.entity.effect.StatusEffectType;
import net.minecraft.util.registry.Registry;
public class AlaskaEffects {
- public static StatusEffect MEDICINAL =
- Registry.register(
- Registry.STATUS_EFFECT,
- "medicinal",
- new MedicinalStatusEffect(StatusEffectCategory.BENEFICIAL, 0x929D2A)
- );
+ public static StatusEffect MEDICINAL =
+ Registry.register(
+ Registry.STATUS_EFFECT,
+ "medicinal",
+ new MedicinalStatusEffect(StatusEffectType.BENEFICIAL, 0x929D2A)
+ );
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java
index 93a13a0a..f1c6fb2a 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java
@@ -2,30 +2,29 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
-import net.minecraft.entity.effect.StatusEffectCategory;
+import net.minecraft.entity.effect.StatusEffectType;
public class MedicinalStatusEffect extends StatusEffect {
+ protected MedicinalStatusEffect(StatusEffectType category, int color) {
+ super(category, color);
+ }
- protected MedicinalStatusEffect(StatusEffectCategory category, int color) {
- super(category, color);
- }
+ @Override
+ public boolean canApplyUpdateEffect(int duration, int amplifier) {
+ // The medicinal effect removes other effects,
+ // It cannot do that at the regular time otherwise it will result in a CME
+ // Therefore applyUpdateEffect will not run in the regular loop
+ return false;
+ }
- @Override
- public boolean canApplyUpdateEffect(int duration, int amplifier) {
- // The medicinal effect removes other effects,
- // It cannot do that at the regular time otherwise it will result in a CME
- // Therefore applyUpdateEffect will not run in the regular loop
- return false;
- }
-
- @Override
- public void applyUpdateEffect(LivingEntity entity, int amplifier) {
- // remove first negative status effect found
- for (StatusEffect type : entity.getActiveStatusEffects().keySet()) {
- if (type.getCategory() == StatusEffectCategory.HARMFUL) {
- entity.removeStatusEffect(type);
- break;
- }
- }
- }
+ @Override
+ public void applyUpdateEffect(LivingEntity entity, int amplifier) {
+ // remove first negative status effect found
+ for (StatusEffect type : entity.getActiveStatusEffects().keySet()) {
+ if (type.getType() == StatusEffectType.HARMFUL) {
+ entity.removeStatusEffect(type);
+ break;
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java
index 1ba9b5aa..cca2c2dc 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java
@@ -1,20 +1,30 @@
package com.github.platymemo.alaskanativecraft.item;
+import java.util.List;
+
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks;
import com.github.platymemo.alaskanativecraft.entity.AlaskaEntities;
import com.github.platymemo.alaskanativecraft.entity.DogsledEntity;
import com.github.platymemo.alaskanativecraft.item.material.AlaskaNativeArmorMaterials;
import com.github.platymemo.alaskanativecraft.mixin.BrewingRecipeRegistryAccessor;
-import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
-import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
-import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
-import net.fabricmc.fabric.api.registry.FuelRegistry;
+
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
-import net.minecraft.item.*;
+import net.minecraft.item.AliasedBlockItem;
+import net.minecraft.item.ArmorItem;
+import net.minecraft.item.BlockItem;
+import net.minecraft.item.DyeableArmorItem;
+import net.minecraft.item.FoodComponent;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemGroup;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.Items;
+import net.minecraft.item.SpawnEggItem;
+import net.minecraft.item.SuspiciousStewItem;
+import net.minecraft.item.ToolMaterials;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.entry.ItemEntry;
@@ -25,156 +35,141 @@
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.registry.Registry;
-import java.util.List;
+import org.quiltmc.qsl.item.group.api.QuiltItemGroup;
+import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
public class AlaskaItems {
- public static final Item MUKTUK;
- public static final Item SEAL;
- public static final Item COOKED_SEAL;
- public static final Item DRY_SEAL;
- public static final Item PTARMIGAN;
- public static final Item COOKED_PTARMIGAN;
- public static final Item VENISON;
- public static final Item COOKED_VENISON;
- public static final Item DRIFTWOOD_CHUNK;
- public static final Item ANTLER;
- public static final Item IVORY;
- public static final Item FISH_STRIP;
- public static final Item DRY_FISH;
- public static final Item BLUEBERRIES;
- public static final Item CLOUDBERRIES;
- public static final Item RASPBERRIES;
- public static final Item SALMONBERRIES;
- public static final Item LABRADOR_TEA;
- public static final SuspiciousStewItem AKUTAQ;
- public static final UluItem ULU;
- public static final HarpoonItem WOODEN_HARPOON;
- public static final HarpoonItem STONE_HARPOON;
- public static final HarpoonItem IRON_HARPOON;
- public static final HarpoonItem GOLDEN_HARPOON;
- public static final HarpoonItem DIAMOND_HARPOON;
- public static final HarpoonItem NETHERITE_HARPOON;
- public static final DyeableArmorItem KUSPUK_HOOD;
- public static final DyeableArmorItem KUSPUK_BODY;
- public static final ArmorItem MUKLUKS;
- public static final ArmorItem SNOW_GOGGLES;
- public static final ArmorItem SNOWSHOES;
- public static final DogsledItem OAK_DOGSLED;
- public static final DogsledItem SPRUCE_DOGSLED;
- public static final DogsledItem BIRCH_DOGSLED;
- public static final DogsledItem JUNGLE_DOGSLED;
- public static final DogsledItem ACACIA_DOGSLED;
- public static final DogsledItem DARK_OAK_DOGSLED;
- public static final SpawnEggItem SEAL_SPAWN_EGG;
- public static final SpawnEggItem PTARMIGAN_SPAWN_EGG;
- public static final SpawnEggItem MOOSE_SPAWN_EGG;
-
- static {
- MUKTUK = register("muktuk", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(1.0F).build())));
- SEAL = register("seal", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build())));
- COOKED_SEAL = register("cooked_seal", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(7).saturationModifier(1.0F).meat().build())));
- DRY_SEAL = register("dry_seal", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(9).saturationModifier(0.2F).meat().build())));
- PTARMIGAN = register("ptarmigan", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 400, 0), 0.5F).meat().build())));
- COOKED_PTARMIGAN = register("cooked_ptarmigan", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(0.6F).meat().build())));
- VENISON = register("venison", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build())));
- COOKED_VENISON = register("cooked_venison", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(8).saturationModifier(0.8F).meat().build())));
-
- DRIFTWOOD_CHUNK = register("driftwood_chunk", new Item(new FabricItemSettings().group(ItemGroup.MISC)));
- ANTLER = register("antler", new Item(new FabricItemSettings().group(ItemGroup.MISC)));
- IVORY = register("ivory", new Item(new FabricItemSettings().group(ItemGroup.MISC)));
-
- FISH_STRIP = register("fish_strip", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(0.1F).snack().build())));
- DRY_FISH = register("dry_fish", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(1F).snack().build())));
-
- BLUEBERRIES = register("blueberries", new AliasedBlockItem(AlaskaBlocks.BLUEBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
- CLOUDBERRIES = register("cloudberries", new AliasedBlockItem(AlaskaBlocks.CLOUDBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
- RASPBERRIES = register("raspberries", new AliasedBlockItem(AlaskaBlocks.RASPBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
- SALMONBERRIES = register("salmonberries", new AliasedBlockItem(AlaskaBlocks.SALMONBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
-
- LABRADOR_TEA = register("labrador_tea", new BlockItem(AlaskaBlocks.LABRADOR_TEA, new FabricItemSettings().group(ItemGroup.BREWING)));
-
- AKUTAQ = register("akutaq", new SuspiciousStewItem(new FabricItemSettings().group(ItemGroup.FOOD).maxCount(1).food(new FoodComponent.Builder().hunger(4).saturationModifier(0.8F).build())));
-
- ULU = register("ulu", new UluItem(new FabricItemSettings().group(ItemGroup.TOOLS).maxDamage(472)));
-
- WOODEN_HARPOON = register("wooden_harpoon", new HarpoonItem(ToolMaterials.WOOD, 4.0F, -2.2F, () -> AlaskaEntities.WOODEN_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT)));
- STONE_HARPOON = register("stone_harpoon", new HarpoonItem(ToolMaterials.STONE, 4.0F, -2.3F, () -> AlaskaEntities.STONE_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT)));
- IRON_HARPOON = register("iron_harpoon", new HarpoonItem(ToolMaterials.IRON, 4.0F, -2.5F, () -> AlaskaEntities.IRON_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT)));
- GOLDEN_HARPOON = register("golden_harpoon", new HarpoonItem(ToolMaterials.GOLD, 4.0F, -2.7F, () -> AlaskaEntities.GOLDEN_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT)));
- DIAMOND_HARPOON = register("diamond_harpoon", new HarpoonItem(ToolMaterials.DIAMOND, 4.0F, -2.7F, () -> AlaskaEntities.DIAMOND_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT)));
- NETHERITE_HARPOON = register("netherite_harpoon", new HarpoonItem(ToolMaterials.NETHERITE, 4.0F, -2.8F, () -> AlaskaEntities.NETHERITE_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT).fireproof()));
-
- KUSPUK_HOOD = register("kuspuk_hood", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.HEAD, new FabricItemSettings().group(ItemGroup.COMBAT)));
- KUSPUK_BODY = register("kuspuk_body", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.CHEST, new FabricItemSettings().group(ItemGroup.COMBAT)));
- MUKLUKS = register("mukluks", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.FEET, new FabricItemSettings().group(ItemGroup.COMBAT)));
-
- SNOW_GOGGLES = register("snow_goggles", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.HEAD, new FabricItemSettings().group(ItemGroup.COMBAT)));
- SNOWSHOES = register("snowshoes", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.FEET, new FabricItemSettings().group(ItemGroup.COMBAT)));
-
- OAK_DOGSLED = register("oak_dogsled", new DogsledItem(DogsledEntity.Type.OAK, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
- SPRUCE_DOGSLED = register("spruce_dogsled", new DogsledItem(DogsledEntity.Type.SPRUCE, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
- BIRCH_DOGSLED = register("birch_dogsled", new DogsledItem(DogsledEntity.Type.BIRCH, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
- JUNGLE_DOGSLED = register("jungle_dogsled", new DogsledItem(DogsledEntity.Type.JUNGLE, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
- ACACIA_DOGSLED = register("acacia_dogsled", new DogsledItem(DogsledEntity.Type.ACACIA, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
- DARK_OAK_DOGSLED = register("dark_oak_dogsled", new DogsledItem(DogsledEntity.Type.DARK_OAK, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
-
- SEAL_SPAWN_EGG = register("seal_spawn_egg", new SpawnEggItem(AlaskaEntities.HARP_SEAL, 8355711, 3355443, new FabricItemSettings().group(ItemGroup.MISC)));
- PTARMIGAN_SPAWN_EGG = register("ptarmigan_spawn_egg", new SpawnEggItem(AlaskaEntities.PTARMIGAN, 13750737, 12763849, new FabricItemSettings().group(ItemGroup.MISC)));
- MOOSE_SPAWN_EGG = register("moose_spawn_egg", new SpawnEggItem(AlaskaEntities.MOOSE, 3811094, 14075317, new FabricItemSettings().group(ItemGroup.MISC)));
- }
-
- private static I register(String name, I item) {
- return Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item);
- }
-
- public static void register() {
- addPotionRecipes();
- addFuels();
- addCompostables();
- addItemGroupEntries();
- addSnowGogglesToLootTable();
- }
-
- private static void addPotionRecipes() {
- for (Potion potion: List.of(Potions.WATER, Potions.MUNDANE, Potions.THICK, Potions.AWKWARD)) {
- BrewingRecipeRegistryAccessor.registerRecipe(potion, AlaskaItems.LABRADOR_TEA, AlaskaPotions.TUNDRA_TEA);
- }
- BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, AlaskaItems.LABRADOR_TEA, AlaskaPotions.STRONG_TUNDRA_TEA);
- BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.GLOWSTONE_DUST, AlaskaPotions.STRONG_TUNDRA_TEA);
- BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.REDSTONE, AlaskaPotions.LONG_TUNDRA_TEA);
- }
-
- private static void addFuels() {
- FuelRegistry fuelRegistry = FuelRegistry.INSTANCE;
- fuelRegistry.add(WOODEN_HARPOON, 200);
- }
-
- private static void addCompostables() {
- CompostingChanceRegistry compostingChanceRegistry = CompostingChanceRegistry.INSTANCE;
- compostingChanceRegistry.add(BLUEBERRIES, 0.3F);
- compostingChanceRegistry.add(CLOUDBERRIES, 0.3F);
- compostingChanceRegistry.add(RASPBERRIES, 0.3F);
- compostingChanceRegistry.add(SALMONBERRIES, 0.3F);
- compostingChanceRegistry.add(LABRADOR_TEA, 0.3F);
- }
-
- private static void addItemGroupEntries() {
- FabricItemGroupBuilder.create(new Identifier(AlaskaNativeCraft.MOD_ID, "items")).icon(() -> MUKTUK.asItem().getDefaultStack()).appendItems(stacks -> Registry.ITEM.forEach(item -> {
- if (Registry.ITEM.getId(item).getNamespace().equals(AlaskaNativeCraft.MOD_ID)) {
- item.appendStacks(item.getGroup(), (DefaultedList) stacks);
- }
- })).build();
- }
-
- private static void addSnowGogglesToLootTable() {
- LootTableEvents.MODIFY.register((resourceManager, lootManager, id, table, source) -> {
- if (LootTables.VILLAGE_SNOWY_HOUSE_CHEST.equals(id) || LootTables.VILLAGE_TAIGA_HOUSE_CHEST.equals(id)) {
- LootPool.Builder poolBuilder = new LootPool.Builder().rolls(UniformLootNumberProvider.create(0.0F, 1.0F))
- .with(ItemEntry.builder(AlaskaItems.SNOW_GOGGLES).build());
-
- table.pool(poolBuilder);
- }
- });
- }
-
+ public static final Item MUKTUK;
+ public static final Item SEAL;
+ public static final Item COOKED_SEAL;
+ public static final Item DRY_SEAL;
+ public static final Item PTARMIGAN;
+ public static final Item COOKED_PTARMIGAN;
+ public static final Item VENISON;
+ public static final Item COOKED_VENISON;
+ public static final Item DRIFTWOOD_CHUNK;
+ public static final Item ANTLER;
+ public static final Item IVORY;
+ public static final Item FISH_STRIP;
+ public static final Item DRY_FISH;
+ public static final Item BLUEBERRIES;
+ public static final Item CLOUDBERRIES;
+ public static final Item RASPBERRIES;
+ public static final Item SALMONBERRIES;
+ public static final Item LABRADOR_TEA;
+ public static final SuspiciousStewItem AKUTAQ;
+ public static final UluItem ULU;
+ public static final HarpoonItem WOODEN_HARPOON;
+ public static final HarpoonItem STONE_HARPOON;
+ public static final HarpoonItem IRON_HARPOON;
+ public static final HarpoonItem GOLDEN_HARPOON;
+ public static final HarpoonItem DIAMOND_HARPOON;
+ public static final HarpoonItem NETHERITE_HARPOON;
+ public static final DyeableArmorItem KUSPUK_HOOD;
+ public static final DyeableArmorItem KUSPUK_BODY;
+ public static final ArmorItem MUKLUKS;
+ public static final ArmorItem SNOW_GOGGLES;
+ public static final ArmorItem SNOWSHOES;
+ public static final DogsledItem OAK_DOGSLED;
+ public static final DogsledItem SPRUCE_DOGSLED;
+ public static final DogsledItem BIRCH_DOGSLED;
+ public static final DogsledItem JUNGLE_DOGSLED;
+ public static final DogsledItem ACACIA_DOGSLED;
+ public static final DogsledItem DARK_OAK_DOGSLED;
+ public static final SpawnEggItem SEAL_SPAWN_EGG;
+ public static final SpawnEggItem PTARMIGAN_SPAWN_EGG;
+ public static final SpawnEggItem MOOSE_SPAWN_EGG;
+
+ static {
+ MUKTUK = register("muktuk", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(1.0F).build())));
+ SEAL = register("seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build())));
+ COOKED_SEAL = register("cooked_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(7).saturationModifier(1.0F).meat().build())));
+ DRY_SEAL = register("dry_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(9).saturationModifier(0.2F).meat().build())));
+ PTARMIGAN = register("ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 400, 0), 0.5F).meat().build())));
+ COOKED_PTARMIGAN = register("cooked_ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(0.6F).meat().build())));
+ VENISON = register("venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build())));
+ COOKED_VENISON = register("cooked_venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(8).saturationModifier(0.8F).meat().build())));
+
+ DRIFTWOOD_CHUNK = register("driftwood_chunk", new Item(new QuiltItemSettings().group(ItemGroup.MISC)));
+ ANTLER = register("antler", new Item(new QuiltItemSettings().group(ItemGroup.MISC)));
+ IVORY = register("ivory", new Item(new QuiltItemSettings().group(ItemGroup.MISC)));
+
+ FISH_STRIP = register("fish_strip", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(0.1F).snack().build())));
+ DRY_FISH = register("dry_fish", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(1F).snack().build())));
+
+ BLUEBERRIES = register("blueberries", new AliasedBlockItem(AlaskaBlocks.BLUEBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
+ CLOUDBERRIES = register("cloudberries", new AliasedBlockItem(AlaskaBlocks.CLOUDBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
+ RASPBERRIES = register("raspberries", new AliasedBlockItem(AlaskaBlocks.RASPBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
+ SALMONBERRIES = register("salmonberries", new AliasedBlockItem(AlaskaBlocks.SALMONBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
+
+ LABRADOR_TEA = register("labrador_tea", new BlockItem(AlaskaBlocks.LABRADOR_TEA, new QuiltItemSettings().group(ItemGroup.BREWING)));
+
+ AKUTAQ = register("akutaq", new SuspiciousStewItem(new QuiltItemSettings().group(ItemGroup.FOOD).maxCount(1).food(new FoodComponent.Builder().hunger(4).saturationModifier(0.8F).build())));
+
+ ULU = register("ulu", new UluItem(new QuiltItemSettings().group(ItemGroup.TOOLS).maxDamage(472)));
+
+ WOODEN_HARPOON = register("wooden_harpoon", new HarpoonItem(ToolMaterials.WOOD, 4.0F, -2.2F, () -> AlaskaEntities.WOODEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ STONE_HARPOON = register("stone_harpoon", new HarpoonItem(ToolMaterials.STONE, 4.0F, -2.3F, () -> AlaskaEntities.STONE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ IRON_HARPOON = register("iron_harpoon", new HarpoonItem(ToolMaterials.IRON, 4.0F, -2.5F, () -> AlaskaEntities.IRON_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ GOLDEN_HARPOON = register("golden_harpoon", new HarpoonItem(ToolMaterials.GOLD, 4.0F, -2.7F, () -> AlaskaEntities.GOLDEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ DIAMOND_HARPOON = register("diamond_harpoon", new HarpoonItem(ToolMaterials.DIAMOND, 4.0F, -2.7F, () -> AlaskaEntities.DIAMOND_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ NETHERITE_HARPOON = register("netherite_harpoon", new HarpoonItem(ToolMaterials.NETHERITE, 4.0F, -2.8F, () -> AlaskaEntities.NETHERITE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT).fireproof()));
+
+ KUSPUK_HOOD = register("kuspuk_hood", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ KUSPUK_BODY = register("kuspuk_body", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.CHEST, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ MUKLUKS = register("mukluks", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+
+ SNOW_GOGGLES = register("snow_goggles", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+ SNOWSHOES = register("snowshoes", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT)));
+
+ OAK_DOGSLED = register("oak_dogsled", new DogsledItem(DogsledEntity.Type.OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
+ SPRUCE_DOGSLED = register("spruce_dogsled", new DogsledItem(DogsledEntity.Type.SPRUCE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
+ BIRCH_DOGSLED = register("birch_dogsled", new DogsledItem(DogsledEntity.Type.BIRCH, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
+ JUNGLE_DOGSLED = register("jungle_dogsled", new DogsledItem(DogsledEntity.Type.JUNGLE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
+ ACACIA_DOGSLED = register("acacia_dogsled", new DogsledItem(DogsledEntity.Type.ACACIA, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
+ DARK_OAK_DOGSLED = register("dark_oak_dogsled", new DogsledItem(DogsledEntity.Type.DARK_OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION)));
+
+ SEAL_SPAWN_EGG = register("seal_spawn_egg", new SpawnEggItem(AlaskaEntities.HARP_SEAL, 8355711, 3355443, new QuiltItemSettings().group(ItemGroup.MISC)));
+ PTARMIGAN_SPAWN_EGG = register("ptarmigan_spawn_egg", new SpawnEggItem(AlaskaEntities.PTARMIGAN, 13750737, 12763849, new QuiltItemSettings().group(ItemGroup.MISC)));
+ MOOSE_SPAWN_EGG = register("moose_spawn_egg", new SpawnEggItem(AlaskaEntities.MOOSE, 3811094, 14075317, new QuiltItemSettings().group(ItemGroup.MISC)));
+ }
+
+ private static I register(String name, I item) {
+ return Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item);
+ }
+
+ public static void register() {
+ addPotionRecipes();
+ addItemGroupEntries();
+ addSnowGogglesToLootTable();
+ }
+
+ private static void addPotionRecipes() {
+ for (Potion potion : List.of(Potions.WATER, Potions.MUNDANE, Potions.THICK, Potions.AWKWARD)) {
+ BrewingRecipeRegistryAccessor.registerRecipe(potion, AlaskaItems.LABRADOR_TEA, AlaskaPotions.TUNDRA_TEA);
+ }
+
+ BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, AlaskaItems.LABRADOR_TEA, AlaskaPotions.STRONG_TUNDRA_TEA);
+ BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.GLOWSTONE_DUST, AlaskaPotions.STRONG_TUNDRA_TEA);
+ BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.REDSTONE, AlaskaPotions.LONG_TUNDRA_TEA);
+ }
+
+ private static void addItemGroupEntries() {
+ QuiltItemGroup.builder(new Identifier(AlaskaNativeCraft.MOD_ID, "items")).icon(() -> MUKTUK.asItem().getDefaultStack()).appendItems(stacks -> Registry.ITEM.forEach(item -> {
+ if (Registry.ITEM.getId(item).getNamespace().equals(AlaskaNativeCraft.MOD_ID)) {
+ item.appendStacks(item.getGroup(), (DefaultedList) stacks);
+ }
+ })).build();
+ }
+
+ private static void addSnowGogglesToLootTable() {
+ LootTableEvents.MODIFY.register((resourceManager, lootManager, id, table, source) -> {
+ if (LootTables.VILLAGE_SNOWY_HOUSE_CHEST.equals(id) || LootTables.VILLAGE_TAIGA_HOUSE_CHEST.equals(id)) {
+ LootPool.Builder poolBuilder = new LootPool.Builder().rolls(UniformLootNumberProvider.create(0.0F, 1.0F))
+ .with(ItemEntry.builder(AlaskaItems.SNOW_GOGGLES).build());
+
+ table.pool(poolBuilder);
+ }
+ });
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java
index dbfe445a..b50f83d2 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java
@@ -1,12 +1,13 @@
package com.github.platymemo.alaskanativecraft.item;
import com.github.platymemo.alaskanativecraft.entity.effect.AlaskaEffects;
+
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.potion.Potion;
import net.minecraft.util.registry.Registry;
public class AlaskaPotions {
- public static final Potion TUNDRA_TEA = Registry.register(Registry.POTION, "tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 1200)));
- public static final Potion LONG_TUNDRA_TEA = Registry.register(Registry.POTION, "long_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 2400)));
- public static final Potion STRONG_TUNDRA_TEA = Registry.register(Registry.POTION, "strong_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 600, 1)));
+ public static final Potion TUNDRA_TEA = Registry.register(Registry.POTION, "tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 1200)));
+ public static final Potion LONG_TUNDRA_TEA = Registry.register(Registry.POTION, "long_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 2400)));
+ public static final Potion STRONG_TUNDRA_TEA = Registry.register(Registry.POTION, "strong_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 600, 1)));
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java
index 102eb217..51bb2e02 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java
@@ -1,6 +1,11 @@
package com.github.platymemo.alaskanativecraft.item;
+import java.util.List;
+import java.util.function.Predicate;
+
import com.github.platymemo.alaskanativecraft.entity.DogsledEntity;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
@@ -14,65 +19,61 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.List;
-import java.util.function.Predicate;
public class DogsledItem extends Item {
- private static final Predicate RIDERS;
+ private static final Predicate RIDERS;
- static {
- RIDERS = EntityPredicates.EXCEPT_SPECTATOR.and(Entity::collides);
- }
+ static {
+ RIDERS = EntityPredicates.EXCEPT_SPECTATOR.and(Entity::collides);
+ }
- private final DogsledEntity.Type type;
+ private final DogsledEntity.Type type;
- public DogsledItem(DogsledEntity.Type type, Item.Settings settings) {
- super(settings);
- this.type = type;
- }
+ public DogsledItem(DogsledEntity.Type type, Item.Settings settings) {
+ super(settings);
+ this.type = type;
+ }
- @Override
- public TypedActionResult use(World world, @NotNull PlayerEntity user, Hand hand) {
- ItemStack itemStack = user.getStackInHand(hand);
- HitResult hitResult = raycast(world, user, RaycastContext.FluidHandling.ANY);
- if (hitResult.getType() == HitResult.Type.MISS) {
- return TypedActionResult.pass(itemStack);
- } else {
- Vec3d vec3d = user.getRotationVec(1.0F);
- List list = world.getOtherEntities(user, user.getBoundingBox().stretch(vec3d.multiply(5.0D)).expand(1.0D), RIDERS);
- if (!list.isEmpty()) {
- Vec3d vec3d2 = user.getCameraPosVec(1.0F);
+ @Override
+ public TypedActionResult use(World world, @NotNull PlayerEntity user, Hand hand) {
+ ItemStack itemStack = user.getStackInHand(hand);
+ HitResult hitResult = raycast(world, user, RaycastContext.FluidHandling.ANY);
+ if (hitResult.getType() == HitResult.Type.MISS) {
+ return TypedActionResult.pass(itemStack);
+ } else {
+ Vec3d vec3d = user.getRotationVec(1.0F);
+ List list = world.getOtherEntities(user, user.getBoundingBox().stretch(vec3d.multiply(5.0D)).expand(1.0D), RIDERS);
+ if (!list.isEmpty()) {
+ Vec3d vec3d2 = user.getCameraPosVec(1.0F);
- for (Entity entity : list) {
- Box box = entity.getBoundingBox().expand(entity.getTargetingMargin());
- if (box.contains(vec3d2)) {
- return TypedActionResult.pass(itemStack);
- }
- }
- }
+ for (Entity entity : list) {
+ Box box = entity.getBoundingBox().expand(entity.getTargetingMargin());
+ if (box.contains(vec3d2)) {
+ return TypedActionResult.pass(itemStack);
+ }
+ }
+ }
- if (hitResult.getType() == HitResult.Type.BLOCK) {
- DogsledEntity dogsledEntity = new DogsledEntity(world, hitResult.getPos().x, hitResult.getPos().y, hitResult.getPos().z);
- dogsledEntity.setDogsledType(this.type);
- dogsledEntity.setBodyYaw(user.getYaw());
- if (!world.isSpaceEmpty(dogsledEntity, dogsledEntity.getBoundingBox().expand(-0.1D))) {
- return TypedActionResult.fail(itemStack);
- } else {
- if (!world.isClient) {
- world.spawnEntity(dogsledEntity);
- if (!user.getAbilities().creativeMode) {
- itemStack.decrement(1);
- }
- }
+ if (hitResult.getType() == HitResult.Type.BLOCK) {
+ DogsledEntity dogsledEntity = new DogsledEntity(world, hitResult.getPos().x, hitResult.getPos().y, hitResult.getPos().z);
+ dogsledEntity.setDogsledType(this.type);
+ dogsledEntity.setBodyYaw(user.getYaw());
+ if (!world.isSpaceEmpty(dogsledEntity, dogsledEntity.getBoundingBox().expand(-0.1D))) {
+ return TypedActionResult.fail(itemStack);
+ } else {
+ if (!world.isClient) {
+ world.spawnEntity(dogsledEntity);
+ if (!user.getAbilities().creativeMode) {
+ itemStack.decrement(1);
+ }
+ }
- user.incrementStat(Stats.USED.getOrCreateStat(this));
- return TypedActionResult.success(itemStack, world.isClient());
- }
- } else {
- return TypedActionResult.pass(itemStack);
- }
- }
- }
+ user.incrementStat(Stats.USED.getOrCreateStat(this));
+ return TypedActionResult.success(itemStack, world.isClient());
+ }
+ } else {
+ return TypedActionResult.pass(itemStack);
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java
index d637353e..e19bc19b 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java
@@ -1,8 +1,12 @@
package com.github.platymemo.alaskanativecraft.item;
+import java.util.function.Supplier;
+
import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -29,124 +33,121 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.Supplier;
public class HarpoonItem extends TridentItem {
-
- private final Multimap attributeModifiers;
-
- private final ToolMaterial material;
- private final float attackDamage;
- private final Supplier> typeSupplier;
- private EntityType cachedType = null;
-
- public HarpoonItem(@NotNull ToolMaterial material, float attackDamage, float attackSpeed, Supplier> typeSupplier, @NotNull Item.Settings settings) {
- super(settings.maxDamageIfAbsent(material.getDurability()));
- this.material = material;
- this.attackDamage = attackDamage + material.getAttackDamage();
- this.typeSupplier = typeSupplier;
- ImmutableMultimap.Builder builder = ImmutableMultimap.builder();
- builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Tool modifier", this.attackDamage - 1, EntityAttributeModifier.Operation.ADDITION));
- builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Tool modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION));
- this.attributeModifiers = builder.build();
- }
-
- public EntityType getType() {
- if (cachedType == null) {
- cachedType = typeSupplier.get();
- }
- return cachedType;
- }
-
- public ToolMaterial getMaterial() {
- return this.material;
- }
-
- @Override
- public int getEnchantability() {
- return this.material.getEnchantability();
- }
-
- @Override
- public boolean canRepair(ItemStack stack, ItemStack ingredient) {
- return this.material.getRepairIngredient().test(ingredient) || super.canRepair(stack, ingredient);
- }
-
- public float getAttackDamage() {
- return this.attackDamage;
- }
-
- @Override
- public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) {
- Block block = state.getBlock();
- if (block == Blocks.COBWEB) {
- return 15.0F;
- } else {
- Material material = state.getMaterial();
- return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && material != Material.MOSS_BLOCK && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F;
- }
- }
-
- @Override
- public Multimap getAttributeModifiers(EquipmentSlot slot) {
- return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(slot);
- }
-
- @Override
- public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
- if (user instanceof PlayerEntity playerEntity) {
- int i = this.getMaxUseTime(stack) - remainingUseTicks;
- if (i >= 10) {
- int j = EnchantmentHelper.getRiptide(stack);
- if (j <= 0 || playerEntity.isTouchingWaterOrRain()) {
- if (!world.isClient && j == 0) {
- stack.damage(1, playerEntity, entity -> entity.sendToolBreakStatus(user.getActiveHand()));
- HarpoonEntity harpoonEntity = new HarpoonEntity(world, playerEntity, this, stack);
- harpoonEntity.setVelocity(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0F, 2.5F, 1.0F);
- if (playerEntity.getAbilities().creativeMode) {
- harpoonEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
- }
-
- world.spawnEntity(harpoonEntity);
- world.playSoundFromEntity(null, harpoonEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
- if (!playerEntity.getAbilities().creativeMode) {
- playerEntity.getInventory().removeOne(stack);
- }
- }
-
- playerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
- if (j > 0) {
- float yaw = playerEntity.getYaw();
- float pitch = playerEntity.getPitch();
- float h = -MathHelper.sin(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F);
- float k = -MathHelper.sin(pitch * 0.017453292F);
- float l = MathHelper.cos(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F);
- float length = MathHelper.sqrt(h * h + k * k + l * l);
- float multiplier = 3.0F * ((1.0F + (float) j) / 5.5F);
- h *= multiplier / length;
- k *= multiplier / length;
- l *= multiplier / length;
- playerEntity.addVelocity(h, k, l);
- playerEntity.useRiptide(20);
- if (playerEntity.isOnGround()) {
- playerEntity.move(MovementType.SELF, new Vec3d(0.0D, 1.2D, 0.0D));
- }
-
- SoundEvent soundEvent;
- if (j >= 3) {
- soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_3;
- } else if (j == 2) {
- soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_2;
- } else {
- soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_1;
- }
-
- world.playSoundFromEntity(null, playerEntity, soundEvent, SoundCategory.PLAYERS, 1.0F, 1.0F);
- }
- }
- }
- }
- }
+ private final Multimap attributeModifiers;
+
+ private final ToolMaterial material;
+ private final float attackDamage;
+ private final Supplier> typeSupplier;
+ private EntityType cachedType = null;
+
+ public HarpoonItem(@NotNull ToolMaterial material, float attackDamage, float attackSpeed, Supplier> typeSupplier, @NotNull Item.Settings settings) {
+ super(settings.maxDamageIfAbsent(material.getDurability()));
+ this.material = material;
+ this.attackDamage = attackDamage + material.getAttackDamage();
+ this.typeSupplier = typeSupplier;
+ ImmutableMultimap.Builder builder = ImmutableMultimap.builder();
+ builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Tool modifier", this.attackDamage - 1, EntityAttributeModifier.Operation.ADDITION));
+ builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Tool modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION));
+ this.attributeModifiers = builder.build();
+ }
+
+ public EntityType getType() {
+ if (this.cachedType == null) {
+ this.cachedType = this.typeSupplier.get();
+ }
+
+ return this.cachedType;
+ }
+
+ public ToolMaterial getMaterial() {
+ return this.material;
+ }
+
+ @Override
+ public int getEnchantability() {
+ return this.material.getEnchantability();
+ }
+
+ @Override
+ public boolean canRepair(ItemStack stack, ItemStack ingredient) {
+ return this.material.getRepairIngredient().test(ingredient) || super.canRepair(stack, ingredient);
+ }
+
+ public float getAttackDamage() {
+ return this.attackDamage;
+ }
+
+ @Override
+ public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) {
+ Block block = state.getBlock();
+ if (block == Blocks.COBWEB) {
+ return 15.0F;
+ } else {
+ Material material = state.getMaterial();
+ return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && material != Material.MOSS_BLOCK && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F;
+ }
+ }
+
+ @Override
+ public Multimap getAttributeModifiers(EquipmentSlot slot) {
+ return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(slot);
+ }
+
+ @Override
+ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
+ if (user instanceof PlayerEntity playerEntity) {
+ int i = this.getMaxUseTime(stack) - remainingUseTicks;
+ if (i >= 10) {
+ int j = EnchantmentHelper.getRiptide(stack);
+ if (j <= 0 || playerEntity.isTouchingWaterOrRain()) {
+ if (!world.isClient && j == 0) {
+ stack.damage(1, playerEntity, entity -> entity.sendToolBreakStatus(user.getActiveHand()));
+ HarpoonEntity harpoonEntity = new HarpoonEntity(world, playerEntity, this, stack);
+ harpoonEntity.setProperties(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0F, 2.5F, 1.0F);
+ if (playerEntity.getAbilities().creativeMode) {
+ harpoonEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
+ }
+
+ world.spawnEntity(harpoonEntity);
+ world.playSoundFromEntity(null, harpoonEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
+ if (!playerEntity.getAbilities().creativeMode) {
+ playerEntity.getInventory().removeOne(stack);
+ }
+ }
+
+ playerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
+ if (j > 0) {
+ float yaw = playerEntity.getYaw();
+ float pitch = playerEntity.getPitch();
+ float h = -MathHelper.sin(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F);
+ float k = -MathHelper.sin(pitch * 0.017453292F);
+ float l = MathHelper.cos(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F);
+ float length = MathHelper.sqrt(h * h + k * k + l * l);
+ float multiplier = 3.0F * ((1.0F + (float) j) / 5.5F);
+ h *= multiplier / length;
+ k *= multiplier / length;
+ l *= multiplier / length;
+ playerEntity.addVelocity(h, k, l);
+ playerEntity.startRiptideAttack(20);
+ if (playerEntity.isOnGround()) {
+ playerEntity.move(MovementType.SELF, new Vec3d(0.0D, 1.2D, 0.0D));
+ }
+
+ SoundEvent soundEvent;
+ if (j >= 3) {
+ soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_3;
+ } else if (j == 2) {
+ soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_2;
+ } else {
+ soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_1;
+ }
+
+ world.playSoundFromEntity(null, playerEntity, soundEvent, SoundCategory.PLAYERS, 1.0F, 1.0F);
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java
index a44a41e8..715a4774 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java
@@ -2,28 +2,28 @@
import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MiningToolItem;
import net.minecraft.item.ToolMaterials;
import net.minecraft.tag.BlockTags;
-import org.jetbrains.annotations.NotNull;
public class UluItem extends MiningToolItem {
+ public UluItem(Settings settings) {
+ super(1.0F, -2.8F, ToolMaterials.IRON, AlaskaTags.ULU_MINEABLE, settings);
+ }
- public UluItem(Settings settings) {
- super(1.0F, -2.8F, ToolMaterials.IRON, AlaskaTags.ULU_MINEABLE, settings);
- }
-
- @Override
- public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) {
- if (!state.isOf(Blocks.COBWEB) && !state.isIn(BlockTags.LEAVES)) {
- return state.isIn(BlockTags.WOOL) ? 5.0F : super.getMiningSpeedMultiplier(stack, state);
- } else if (state.isOf(AlaskaBlocks.WHALE_MEAT_BLOCK)) {
- return 1.5F;
- } else {
- return 15.0F;
- }
- }
+ @Override
+ public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) {
+ if (!state.isOf(Blocks.COBWEB) && !state.isIn(BlockTags.LEAVES)) {
+ return state.isIn(BlockTags.WOOL) ? 5.0F : super.getMiningSpeedMultiplier(stack, state);
+ } else if (state.isOf(AlaskaBlocks.WHALE_MEAT_BLOCK)) {
+ return 1.5F;
+ } else {
+ return 15.0F;
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java
index 7474eff5..51f38107 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java
@@ -2,79 +2,78 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.tag.ItemTags;
-import org.jetbrains.annotations.NotNull;
public enum AlaskaNativeArmorMaterials implements ArmorMaterial {
+ KUSPUK("kuspuk", 5, new int[] {1, 0, 3, 1}, 15, SoundEvents.BLOCK_WOOL_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.WOOL)),
+ SNOW_GEAR("snow_goggles", 5, new int[] {1, 0, 0, 1}, 25, SoundEvents.BLOCK_WOOD_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.PLANKS));
- KUSPUK("kuspuk", 5, new int[]{1, 0, 3, 1}, 15, SoundEvents.BLOCK_WOOL_STEP, 0.0F, 0.0F, Ingredient.fromTag(ItemTags.WOOL)),
-
- SNOW_GEAR("snow_goggles", 5, new int[]{1, 0, 0, 1}, 25, SoundEvents.BLOCK_WOOD_STEP, 0.0F, 0.0F, Ingredient.fromTag(ItemTags.PLANKS));
-
- private static final int[] BASE_DURABILITY = new int[]{13, 15, 16, 11};
- private final String name;
- private final int durabilityMultiplier;
- private final int[] protectionAmounts;
- private final int enchantability;
- private final SoundEvent equipSound;
- private final float toughness;
- private final float knockbackResistance;
- private final Ingredient repairIngredient;
+ private static final int[] BASE_DURABILITY = new int[] {13, 15, 16, 11};
+ private final String name;
+ private final int durabilityMultiplier;
+ private final int[] protectionAmounts;
+ private final int enchantability;
+ private final SoundEvent equipSound;
+ private final float toughness;
+ private final float knockbackResistance;
+ private final Ingredient repairIngredient;
- AlaskaNativeArmorMaterials(String name, int durabilityMultiplier, int[] protectionAmounts, int enchantability, SoundEvent equipSound, float toughness, float knockbackResistance, Ingredient repairIngredient) {
- this.name = name;
- this.durabilityMultiplier = durabilityMultiplier;
- this.protectionAmounts = protectionAmounts;
- this.enchantability = enchantability;
- this.equipSound = equipSound;
- this.toughness = toughness;
- this.knockbackResistance = knockbackResistance;
- this.repairIngredient = repairIngredient;
- }
+ AlaskaNativeArmorMaterials(String name, int durabilityMultiplier, int[] protectionAmounts, int enchantability, SoundEvent equipSound, float toughness, float knockbackResistance, Ingredient repairIngredient) {
+ this.name = name;
+ this.durabilityMultiplier = durabilityMultiplier;
+ this.protectionAmounts = protectionAmounts;
+ this.enchantability = enchantability;
+ this.equipSound = equipSound;
+ this.toughness = toughness;
+ this.knockbackResistance = knockbackResistance;
+ this.repairIngredient = repairIngredient;
+ }
- @Override
- public int getDurability(@NotNull EquipmentSlot slot) {
- return BASE_DURABILITY[slot.getEntitySlotId()] * this.durabilityMultiplier;
- }
+ @Override
+ public int getDurability(@NotNull EquipmentSlot slot) {
+ return BASE_DURABILITY[slot.getEntitySlotId()] * this.durabilityMultiplier;
+ }
- @Override
- public int getProtectionAmount(@NotNull EquipmentSlot slot) {
- return this.protectionAmounts[slot.getEntitySlotId()];
- }
+ @Override
+ public int getProtectionAmount(@NotNull EquipmentSlot slot) {
+ return this.protectionAmounts[slot.getEntitySlotId()];
+ }
- @Override
- public int getEnchantability() {
- return this.enchantability;
- }
+ @Override
+ public int getEnchantability() {
+ return this.enchantability;
+ }
- @Override
- public SoundEvent getEquipSound() {
- return this.equipSound;
- }
+ @Override
+ public SoundEvent getEquipSound() {
+ return this.equipSound;
+ }
- @Override
- public Ingredient getRepairIngredient() {
- return this.repairIngredient;
- }
+ @Override
+ public Ingredient getRepairIngredient() {
+ return this.repairIngredient;
+ }
- @Override
- @Environment(EnvType.CLIENT)
- public String getName() {
- return this.name;
- }
+ @Override
+ @Environment(EnvType.CLIENT)
+ public String getName() {
+ return this.name;
+ }
- @Override
- public float getToughness() {
- return this.toughness;
- }
+ @Override
+ public float getToughness() {
+ return this.toughness;
+ }
- @Override
- public float getKnockbackResistance() {
- return this.knockbackResistance;
- }
+ @Override
+ public float getKnockbackResistance() {
+ return this.knockbackResistance;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java
index 4f071d3c..b184b40e 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java
@@ -1,14 +1,15 @@
package com.github.platymemo.alaskanativecraft.loot.function;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
+
import net.minecraft.loot.function.LootFunctionType;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class AlaskaLootFunctionTypes {
- public static final LootFunctionType SET_AKUTAQ_EFFECT = new LootFunctionType(new SetAkutaqEffectsLootFunction.Serializer());
+ public static final LootFunctionType SET_AKUTAQ_EFFECT = new LootFunctionType(new SetAkutaqEffectsLootFunction.Serializer());
- public static void register() {
- Registry.register(Registry.LOOT_FUNCTION_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "set_akutaq_effects"), SET_AKUTAQ_EFFECT);
- }
+ public static void register() {
+ Registry.register(Registry.LOOT_FUNCTION_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "set_akutaq_effects"), SET_AKUTAQ_EFFECT);
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java
index 06a3799a..bd6fe348 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java
@@ -1,12 +1,23 @@
package com.github.platymemo.alaskanativecraft.loot.function;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.recipe.AkutaqRecipe;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
-import com.google.gson.*;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSyntaxException;
+
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.condition.LootCondition;
@@ -21,130 +32,126 @@
import net.minecraft.util.JsonHelper;
import net.minecraft.util.registry.Registry;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
public class SetAkutaqEffectsLootFunction extends ConditionalLootFunction {
- final Map effects;
- final LootNumberProvider amountNumberProvider;
-
- SetAkutaqEffectsLootFunction(LootCondition[] conditions, Map effects, LootNumberProvider amountNumberProvider) {
- super(conditions);
- this.effects = ImmutableMap.copyOf(effects);
- this.amountNumberProvider = amountNumberProvider;
- }
-
- public static SetAkutaqEffectsLootFunction.Builder builder() {
- return new SetAkutaqEffectsLootFunction.Builder();
- }
-
- @Override
- public LootFunctionType getType() {
- return AlaskaLootFunctionTypes.SET_AKUTAQ_EFFECT;
- }
-
- @Override
- public Set> getRequiredParameters() {
- return this.effects
- .values()
- .stream()
- .flatMap(numberProvider -> numberProvider.getRequiredParameters().stream())
- .collect(ImmutableSet.toImmutableSet());
- }
-
- @Override
- public ItemStack process(ItemStack stack, LootContext context) {
- if (stack.isOf(AlaskaItems.AKUTAQ) && !this.effects.isEmpty()) {
- for (int i = 0; i < this.amountNumberProvider.nextInt(context); i++) {
- int selectedInt = context.getRandom().nextInt(this.effects.size());
- Entry entry = Iterables.get(this.effects.entrySet(), selectedInt);
- StatusEffect statusEffect = entry.getKey();
- int duration = entry.getValue().nextInt(context);
- if (!statusEffect.isInstant()) {
- duration *= 20;
- }
-
- AkutaqRecipe.addEffectToAkutaq(stack, statusEffect, duration);
- }
- }
- return stack;
- }
-
- public static class Builder extends ConditionalLootFunction.Builder {
- private final Map map = Maps.newHashMap();
- private LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(0.0F);
-
- @Override
- protected SetAkutaqEffectsLootFunction.Builder getThisBuilder() {
- return this;
- }
-
- public SetAkutaqEffectsLootFunction.Builder withAmount(LootNumberProvider amountRange) {
- this.amountNumberProvider = amountRange;
- return this;
- }
-
- public SetAkutaqEffectsLootFunction.Builder withEffect(StatusEffect effect, LootNumberProvider durationRange) {
- this.map.put(effect, durationRange);
- return this;
- }
-
- @Override
- public LootFunction build() {
- return new SetAkutaqEffectsLootFunction(this.getConditions(), this.map, amountNumberProvider);
- }
- }
-
- public static class Serializer extends ConditionalLootFunction.Serializer {
- @Override
- public void toJson(JsonObject jsonObject, SetAkutaqEffectsLootFunction lootFunction, JsonSerializationContext jsonSerializationContext) {
- super.toJson(jsonObject, lootFunction, jsonSerializationContext);
- if (!lootFunction.effects.isEmpty()) {
- JsonArray jsonArray = new JsonArray();
-
- for (StatusEffect statusEffect : lootFunction.effects.keySet()) {
- JsonObject jsonObject2 = new JsonObject();
- Identifier identifier = Registry.STATUS_EFFECT.getId(statusEffect);
- if (identifier == null) {
- throw new IllegalArgumentException("Don't know how to serialize mob effect " + statusEffect);
- }
-
- jsonObject2.add("type", new JsonPrimitive(identifier.toString()));
- jsonObject2.add("duration", jsonSerializationContext.serialize(lootFunction.effects.get(statusEffect)));
- jsonArray.add(jsonObject2);
- }
-
- jsonObject.add("effects", jsonArray);
- }
-
- }
-
- @Override
- public SetAkutaqEffectsLootFunction fromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext, LootCondition[] lootConditions) {
- Map map = Maps.newHashMap();
- if (jsonObject.has("effects")) {
- for (JsonElement jsonElement : JsonHelper.getArray(jsonObject, "effects")) {
- String string = JsonHelper.getString(jsonElement.getAsJsonObject(), "type");
- StatusEffect statusEffect = Registry.STATUS_EFFECT
- .getOrEmpty(new Identifier(string))
- .orElseThrow(() -> new JsonSyntaxException("Unknown mob effect '" + string + "'"));
- LootNumberProvider lootNumberProvider = JsonHelper.deserialize(
- jsonElement.getAsJsonObject(), "duration", jsonDeserializationContext, LootNumberProvider.class
- );
-
- map.put(statusEffect, lootNumberProvider);
- }
- }
-
- LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(1.0F);
- if (jsonObject.has("amount")) {
- amountNumberProvider = JsonHelper.deserialize(
- jsonObject, "amount", jsonDeserializationContext, LootNumberProvider.class
- );
- }
-
- return new SetAkutaqEffectsLootFunction(lootConditions, map, amountNumberProvider);
- }
- }
+ final Map effects;
+ final LootNumberProvider amountNumberProvider;
+
+ SetAkutaqEffectsLootFunction(LootCondition[] conditions, Map effects, LootNumberProvider amountNumberProvider) {
+ super(conditions);
+ this.effects = ImmutableMap.copyOf(effects);
+ this.amountNumberProvider = amountNumberProvider;
+ }
+
+ public static SetAkutaqEffectsLootFunction.Builder builder() {
+ return new SetAkutaqEffectsLootFunction.Builder();
+ }
+
+ @Override
+ public LootFunctionType getType() {
+ return AlaskaLootFunctionTypes.SET_AKUTAQ_EFFECT;
+ }
+
+ @Override
+ public Set> getRequiredParameters() {
+ return this.effects
+ .values()
+ .stream()
+ .flatMap(numberProvider -> numberProvider.getRequiredParameters().stream())
+ .collect(ImmutableSet.toImmutableSet());
+ }
+
+ @Override
+ public ItemStack process(ItemStack stack, LootContext context) {
+ if (stack.isOf(AlaskaItems.AKUTAQ) && !this.effects.isEmpty()) {
+ for (int i = 0; i < this.amountNumberProvider.nextInt(context); i++) {
+ int selectedInt = context.getRandom().nextInt(this.effects.size());
+ Entry entry = Iterables.get(this.effects.entrySet(), selectedInt);
+ StatusEffect statusEffect = entry.getKey();
+ int duration = entry.getValue().nextInt(context);
+ if (!statusEffect.isInstant()) {
+ duration *= 20;
+ }
+
+ AkutaqRecipe.addEffectToAkutaq(stack, statusEffect, duration);
+ }
+ }
+
+ return stack;
+ }
+
+ public static class Builder extends ConditionalLootFunction.Builder {
+ private final Map map = Maps.newHashMap();
+ private LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(0.0F);
+
+ @Override
+ protected SetAkutaqEffectsLootFunction.Builder getThisBuilder() {
+ return this;
+ }
+
+ public SetAkutaqEffectsLootFunction.Builder withAmount(LootNumberProvider amountRange) {
+ this.amountNumberProvider = amountRange;
+ return this;
+ }
+
+ public SetAkutaqEffectsLootFunction.Builder withEffect(StatusEffect effect, LootNumberProvider durationRange) {
+ this.map.put(effect, durationRange);
+ return this;
+ }
+
+ @Override
+ public LootFunction build() {
+ return new SetAkutaqEffectsLootFunction(this.getConditions(), this.map, this.amountNumberProvider);
+ }
+ }
+
+ public static class Serializer extends ConditionalLootFunction.Serializer {
+ @Override
+ public void toJson(JsonObject jsonObject, SetAkutaqEffectsLootFunction lootFunction, JsonSerializationContext jsonSerializationContext) {
+ super.toJson(jsonObject, lootFunction, jsonSerializationContext);
+ if (!lootFunction.effects.isEmpty()) {
+ JsonArray jsonArray = new JsonArray();
+
+ for (StatusEffect statusEffect : lootFunction.effects.keySet()) {
+ JsonObject jsonObject2 = new JsonObject();
+ Identifier identifier = Registry.STATUS_EFFECT.getId(statusEffect);
+ if (identifier == null) {
+ throw new IllegalArgumentException("Don't know how to serialize mob effect " + statusEffect);
+ }
+
+ jsonObject2.add("type", new JsonPrimitive(identifier.toString()));
+ jsonObject2.add("duration", jsonSerializationContext.serialize(lootFunction.effects.get(statusEffect)));
+ jsonArray.add(jsonObject2);
+ }
+
+ jsonObject.add("effects", jsonArray);
+ }
+ }
+
+ @Override
+ public SetAkutaqEffectsLootFunction fromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext, LootCondition[] lootConditions) {
+ Map map = Maps.newHashMap();
+ if (jsonObject.has("effects")) {
+ for (JsonElement jsonElement : JsonHelper.getArray(jsonObject, "effects")) {
+ String string = JsonHelper.getString(jsonElement.getAsJsonObject(), "type");
+ StatusEffect statusEffect = Registry.STATUS_EFFECT
+ .getOrEmpty(new Identifier(string))
+ .orElseThrow(() -> new JsonSyntaxException("Unknown mob effect '" + string + "'"));
+ LootNumberProvider lootNumberProvider = JsonHelper.deserialize(
+ jsonElement.getAsJsonObject(), "duration", jsonDeserializationContext, LootNumberProvider.class
+ );
+
+ map.put(statusEffect, lootNumberProvider);
+ }
+ }
+
+ LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(1.0F);
+ if (jsonObject.has("amount")) {
+ amountNumberProvider = JsonHelper.deserialize(
+ jsonObject, "amount", jsonDeserializationContext, LootNumberProvider.class
+ );
+ }
+
+ return new SetAkutaqEffectsLootFunction(lootConditions, map, amountNumberProvider);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java
index f1df68b8..815fcd0c 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java
@@ -1,10 +1,6 @@
package com.github.platymemo.alaskanativecraft.mixin;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.item.Items;
-import net.minecraft.screen.*;
import org.jetbrains.annotations.Nullable;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
@@ -14,33 +10,41 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.Items;
+import net.minecraft.screen.AnvilScreenHandler;
+import net.minecraft.screen.ForgingScreenHandler;
+import net.minecraft.screen.Property;
+import net.minecraft.screen.ScreenHandlerContext;
+import net.minecraft.screen.ScreenHandlerType;
+
@Mixin(AnvilScreenHandler.class)
public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler {
+ @Shadow
+ @Final
+ private final Property levelCost;
- @Shadow
- @Final
- private final Property levelCost;
-
- @Shadow
- private int repairItemUsage;
+ @Shadow
+ private int repairItemUsage;
- protected AnvilScreenHandlerMixin(@Nullable ScreenHandlerType> type, int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
- super(type, syncId, playerInventory, context);
- throw new AssertionError("AlaskaNativeCraft's AnvilScreenHandlerMixin constructor called!");
- }
+ protected AnvilScreenHandlerMixin(@Nullable ScreenHandlerType> type, int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
+ super(type, syncId, playerInventory, context);
+ throw new AssertionError("AlaskaNativeCraft's AnvilScreenHandlerMixin constructor called!");
+ }
- @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), method = "updateResult", cancellable = true)
- private void addLeashedHarpoon(CallbackInfo ci) {
- ItemStack base = this.input.getStack(0);
- ItemStack addition = this.input.getStack(1);
- if (base.isIn(AlaskaTags.HARPOONS) && !base.getOrCreateNbt().getBoolean("leashed") && addition.isOf(Items.LEAD)) {
- ItemStack result = base.copy();
- result.getOrCreateNbt().putInt("leashed", addition.getCount());
- this.output.setStack(0, result);
- this.levelCost.set(1);
- this.repairItemUsage = 1;
- sendContentUpdates();
- ci.cancel();
- }
- }
+ @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), method = "updateResult", cancellable = true)
+ private void addLeashedHarpoon(CallbackInfo ci) {
+ ItemStack base = this.input.getStack(0);
+ ItemStack addition = this.input.getStack(1);
+ if (base.isIn(AlaskaTags.HARPOONS) && !base.getOrCreateNbt().getBoolean("leashed") && addition.isOf(Items.LEAD)) {
+ ItemStack result = base.copy();
+ result.getOrCreateNbt().putInt("leashed", addition.getCount());
+ this.output.setStack(0, result);
+ this.levelCost.set(1);
+ this.repairItemUsage = 1;
+ sendContentUpdates();
+ ci.cancel();
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java
index c25222a3..a01bbdd9 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java
@@ -1,16 +1,17 @@
package com.github.platymemo.alaskanativecraft.mixin;
-import net.minecraft.block.Block;
-import net.minecraft.item.AxeItem;
+import java.util.Map;
+
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
-import java.util.Map;
+import net.minecraft.block.Block;
+import net.minecraft.item.AxeItem;
@Mixin(AxeItem.class)
public interface AxeItemAccessor {
- @Accessor("STRIPPED_BLOCKS")
- static Map getStrippedBlocks() {
- throw new AssertionError("Accessor dummy method called somehow!");
- }
+ @Accessor("STRIPPED_BLOCKS")
+ static Map getStrippedBlocks() {
+ throw new AssertionError("Accessor dummy method called somehow!");
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java
index 941d528d..69ebd170 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java
@@ -1,15 +1,16 @@
package com.github.platymemo.alaskanativecraft.mixin;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Invoker;
+
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.recipe.BrewingRecipeRegistry;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(BrewingRecipeRegistry.class)
public interface BrewingRecipeRegistryAccessor {
- @Invoker("registerPotionRecipe")
- static void registerRecipe(Potion input, Item item, Potion output) {
- throw new AssertionError("Something is very wrong!! Dummy method in BrewingRecipeRegistryAccessor called!");
- }
+ @Invoker("registerPotionRecipe")
+ static void registerRecipe(Potion input, Item item, Potion output) {
+ throw new AssertionError("Something is very wrong!! Dummy method in BrewingRecipeRegistryAccessor called!");
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java
index 94b081ef..d9c02389 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java
@@ -1,6 +1,13 @@
package com.github.platymemo.alaskanativecraft.mixin;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
+import org.jetbrains.annotations.NotNull;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.Angerable;
import net.minecraft.entity.mob.EndermanEntity;
@@ -8,28 +15,21 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(EndermanEntity.class)
public abstract class EndermanEntityMixin extends HostileEntity implements Angerable {
+ protected EndermanEntityMixin(EntityType extends HostileEntity> entityType, World world) {
+ super(entityType, world);
+ throw new AssertionError("Mixin constructor called, something is very wrong!");
+ }
- protected EndermanEntityMixin(EntityType extends HostileEntity> entityType, World world) {
- super(entityType, world);
- throw new AssertionError("Mixin constructor called, something is very wrong!");
- }
-
- @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z", ordinal = 0),
- method = "isPlayerStaring(Lnet/minecraft/entity/player/PlayerEntity;)Z",
- locals = LocalCapture.CAPTURE_FAILHARD,
- cancellable = true)
- private void isPlayerWearingSnowGoggles(PlayerEntity player, CallbackInfoReturnable cir, @NotNull ItemStack stack) {
- if (stack.isOf(AlaskaItems.SNOW_GOGGLES.asItem())) {
- cir.setReturnValue(false);
- }
- }
+ @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z", ordinal = 0),
+ method = "isPlayerStaring(Lnet/minecraft/entity/player/PlayerEntity;)Z",
+ locals = LocalCapture.CAPTURE_FAILHARD,
+ cancellable = true)
+ private void isPlayerWearingSnowGoggles(PlayerEntity player, CallbackInfoReturnable cir, @NotNull ItemStack stack) {
+ if (stack.isOf(AlaskaItems.SNOW_GOGGLES.asItem())) {
+ cir.setReturnValue(false);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java
index ac861c5e..6b876b06 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java
@@ -1,28 +1,30 @@
package com.github.platymemo.alaskanativecraft.mixin;
import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.FoxEntity;
import net.minecraft.world.World;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(FoxEntity.class)
public abstract class FoxMixin extends AnimalEntity {
+ protected FoxMixin(EntityType extends AnimalEntity> type, World world) {
+ super(type, world);
+ throw new AssertionError("AlaskaNativeCraft's FoxMixin constructor called!");
+ }
- protected FoxMixin(EntityType extends AnimalEntity> type, World world) {
- super(type, world);
- throw new AssertionError("AlaskaNativeCraft's FoxMixin constructor called!");
- }
-
- @Inject(at = @At("HEAD"), method = "method_18262", cancellable = true, remap = false)
- private static void addPtarmiganTarget(LivingEntity entity, CallbackInfoReturnable cir) {
- if (entity instanceof PtarmiganEntity) {
- cir.setReturnValue(true);
- }
- }
+ // Mixin to the lambdas for chicken and rabbit predicate
+ // There is some very weird stuff happening, but it works:tm:
+ @Inject(at = @At("HEAD"), method = {"m_hklcoapa", "m_clkjuklc", "method_18262", "method_18261"}, cancellable = true, require = 1, remap = false)
+ private static void addPtarmiganTarget(LivingEntity entity, CallbackInfoReturnable cir) {
+ if (entity instanceof PtarmiganEntity) {
+ cir.setReturnValue(true);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java
index 7591e667..18230605 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java
@@ -1,9 +1,5 @@
package com.github.platymemo.alaskanativecraft.mixin;
-import net.minecraft.inventory.Inventory;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.screen.GrindstoneScreenHandler;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -13,22 +9,27 @@
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import net.minecraft.inventory.Inventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.screen.GrindstoneScreenHandler;
+
@Mixin(GrindstoneScreenHandler.class)
public abstract class GrindstoneScreenHandlerMixin {
- @Shadow
- @Final
- Inventory input;
+ @Shadow
+ @Final
+ Inventory input;
- @Redirect(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I"))
- private int redirectGetMaxDamage(Item item) {
- return this.input.getStack(0).getMaxDamage();
- }
+ @Redirect(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I"))
+ private int redirectGetMaxDamage(Item item) {
+ return this.input.getStack(0).getMaxDamage();
+ }
- @SuppressWarnings("ConstantConditions")
- @Inject(method = "transferEnchantments", at = @At("RETURN"))
- private void copyDurabilityMultiplier(ItemStack target, @NotNull ItemStack source, CallbackInfoReturnable cir) {
- if (source.hasNbt() && source.getNbt().contains("DurabilityMultiplier")) {
- cir.getReturnValue().getNbt().putFloat("DurabilityMultiplier", source.getOrCreateNbt().getFloat("DurabilityMultiplier"));
- }
- }
+ @SuppressWarnings("ConstantConditions")
+ @Inject(method = "transferEnchantments", at = @At("RETURN"))
+ private void copyDurabilityMultiplier(ItemStack target, @NotNull ItemStack source, CallbackInfoReturnable cir) {
+ if (source.hasNbt() && source.getNbt().contains("DurabilityMultiplier")) {
+ cir.getReturnValue().getNbt().putFloat("DurabilityMultiplier", source.getOrCreateNbt().getFloat("DurabilityMultiplier"));
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java
index b76a1f90..81c5a742 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java
@@ -1,57 +1,63 @@
package com.github.platymemo.alaskanativecraft.mixin;
import com.github.platymemo.alaskanativecraft.entity.DogsledEntity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
import net.minecraft.loot.LootTables;
-import net.minecraft.structure.*;
+import net.minecraft.structure.IglooGenerator;
+import net.minecraft.structure.Structure;
+import net.minecraft.structure.StructureManager;
+import net.minecraft.structure.StructurePlacementData;
+import net.minecraft.structure.StructureTemplateManager;
+import net.minecraft.structure.piece.SimpleStructurePiece;
+import net.minecraft.structure.piece.StructurePieceType;
import net.minecraft.text.Text;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
-import net.minecraft.util.math.random.Random;
+import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.StructureWorldAccess;
-import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(IglooGenerator.Piece.class)
public abstract class IglooGeneratorMixin extends SimpleStructurePiece {
- private static final Identifier DOGSLED_LOOT_TABLE = LootTables.VILLAGE_SNOWY_HOUSE_CHEST;
- private static BlockPos lastPos;
+ private static final Identifier DOGSLED_LOOT_TABLE = LootTables.VILLAGE_SNOWY_HOUSE_CHEST;
+ private static BlockPos lastPos;
- @Shadow
- private static StructurePlacementData createPlacementData(BlockRotation rotation, Identifier identifier) {
- throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!");
- }
+ protected IglooGeneratorMixin(StructureTemplateManager manager, Identifier identifier, BlockPos pos, BlockRotation rotation, int yOffset) {
+ super(StructurePieceType.IGLOO, 0, manager, identifier, identifier.toString(), createPlacementData(rotation, identifier), getPosOffset(identifier, pos, yOffset));
+ throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin constructor called!");
+ }
- @Shadow
- private static BlockPos getPosOffset(Identifier identifier, BlockPos pos, int yOffset) {
- throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!");
- }
+ @Shadow
+ private static StructurePlacementData createPlacementData(BlockRotation rotation, Identifier identifier) {
+ throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!");
+ }
- protected IglooGeneratorMixin(StructureTemplateManager manager, Identifier identifier, BlockPos pos, BlockRotation rotation, int yOffset) {
- super(StructurePieceType.IGLOO, 0, manager, identifier, identifier.toString(), createPlacementData(rotation, identifier), getPosOffset(identifier, pos, yOffset));
- throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin constructor called!");
- }
+ @Shadow
+ private static BlockPos getPosOffset(Identifier identifier, BlockPos pos, int yOffset) {
+ throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!");
+ }
- @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/SimpleStructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V", shift = At.Shift.AFTER),
- method = "generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V",
- locals = LocalCapture.CAPTURE_FAILSOFT)
- private void addDogsleds(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox chunkBox, ChunkPos chunkPos, BlockPos pos, CallbackInfo ci, Identifier identifier, StructurePlacementData structurePlacementData) {
- BlockPos chestLocation = this.pos.add(StructureTemplate.transform(structurePlacementData, new BlockPos(0, 1, 0)));
- if (lastPos == null || !lastPos.equals(chestLocation)) {
- DogsledEntity dogsled = new DogsledEntity(world.toServerWorld(), (double) chestLocation.getX() + 0.5D, (double) chestLocation.getY() + 0.5D, (double) chestLocation.getZ() + 0.5D);
- dogsled.setDogsledType(DogsledEntity.Type.SPRUCE);
- dogsled.setCustomName(Text.literal("Abandoned Dogsled"));
- dogsled.setLootTable(DOGSLED_LOOT_TABLE, random.nextLong());
- world.spawnEntity(dogsled);
- lastPos = chestLocation;
- }
- }
+ @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/piece/SimpleStructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/structure/StructureManager;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/random/RandomGenerator;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V", shift = At.Shift.AFTER),
+ method = "generate",
+ locals = LocalCapture.CAPTURE_FAILHARD)
+ private void addDogsleds(StructureWorldAccess world, StructureManager structureManager, ChunkGenerator chunkGenerator, RandomGenerator random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos pos, CallbackInfo ci, Identifier id, StructurePlacementData structurePlacementData) {
+ BlockPos chestLocation = this.pos.add(Structure.transform(structurePlacementData, new BlockPos(0, 1, 0)));
+ if (lastPos == null || !lastPos.equals(chestLocation)) {
+ DogsledEntity dogsled = new DogsledEntity(world.toServerWorld(), (double) chestLocation.getX() + 0.5D, (double) chestLocation.getY() + 0.5D, (double) chestLocation.getZ() + 0.5D);
+ dogsled.setDogsledType(DogsledEntity.Type.SPRUCE);
+ dogsled.setCustomName(Text.literal("Abandoned Dogsled"));
+ dogsled.setLootTable(DOGSLED_LOOT_TABLE, random.nextLong());
+ world.spawnEntity(dogsled);
+ lastPos = chestLocation;
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java
index 347cffd6..59cb90ef 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java
@@ -2,23 +2,23 @@
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
import com.google.gson.JsonObject;
-import net.minecraft.item.Item;
-import net.minecraft.item.Items;
-import net.minecraft.recipe.Ingredient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+import net.minecraft.item.Item;
+import net.minecraft.item.Items;
+import net.minecraft.recipe.Ingredient;
+
@Mixin(Ingredient.class)
public class IngredientMixin {
-
- @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/recipe/ShapedRecipe;getItem(Lcom/google/gson/JsonObject;)Lnet/minecraft/item/Item;"),
- method = "entryFromJson", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
- private static void addDriftwoodAntlersAndIvory(JsonObject json, CallbackInfoReturnable cir, Item item) {
- if (item == Items.STICK) {
- cir.setReturnValue(new Ingredient.TagEntry(AlaskaTags.STICKS));
- }
- }
+ @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/recipe/ShapedRecipe;getItem(Lcom/google/gson/JsonObject;)Lnet/minecraft/item/Item;"),
+ method = "entryFromJson", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
+ private static void addDriftwoodAntlersAndIvory(JsonObject json, CallbackInfoReturnable cir, Item item) {
+ if (item == Items.STICK) {
+ cir.setReturnValue(new Ingredient.TagEntry(AlaskaTags.STICKS));
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java
index a4659375..a2f0ca97 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java
@@ -1,29 +1,31 @@
package com.github.platymemo.alaskanativecraft.mixin;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
@Mixin(Item.class)
public abstract class ItemMixin {
- @Shadow
- @Final
- private int maxDamage;
+ @Shadow
+ @Final
+ private int maxDamage;
+
+ @Shadow
+ public abstract boolean isDamageable();
- @Shadow
- public abstract boolean isDamageable();
+ @SuppressWarnings("ConstantConditions")
+ @Redirect(method = {"getItemBarStep", "getItemBarColor"}, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I"))
+ private int redirectForDurabilityMultiplier(Item item, ItemStack stack) {
+ int newMaxDamage = this.maxDamage;
+ if (this.isDamageable() && stack.hasNbt() && stack.getNbt().contains("DurabilityMultiplier")) {
+ newMaxDamage *= stack.getNbt().getFloat("DurabilityMultiplier");
+ }
- @SuppressWarnings("ConstantConditions")
- @Redirect(method = {"getItemBarStep", "getItemBarColor"}, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I"))
- private int redirectForDurabilityMultiplier(Item item, ItemStack stack) {
- int newMaxDamage = this.maxDamage;
- if (this.isDamageable() && stack.hasNbt() && stack.getNbt().contains("DurabilityMultiplier")) {
- newMaxDamage *= stack.getNbt().getFloat("DurabilityMultiplier");
- }
- return newMaxDamage;
- }
+ return newMaxDamage;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java
index f8ce8d6c..7c545d07 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java
@@ -1,7 +1,5 @@
package com.github.platymemo.alaskanativecraft.mixin;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -9,23 +7,25 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NbtCompound;
+
@Mixin(ItemStack.class)
public abstract class ItemStackMixin {
+ @Shadow
+ @Nullable
+ public abstract NbtCompound getNbt();
- @Shadow
- @Nullable
- public abstract NbtCompound getNbt();
-
- @Shadow
- public abstract boolean hasNbt();
+ @Shadow
+ public abstract boolean hasNbt();
- @SuppressWarnings("ConstantConditions")
- @Inject(method = "getMaxDamage", at = @At("RETURN"), cancellable = true)
- private void durabilityMultiplier(CallbackInfoReturnable cir) {
- if (this.hasNbt() && this.getNbt().contains("DurabilityMultiplier")) {
- int newDurability = cir.getReturnValue();
- newDurability *= this.getNbt().getFloat("DurabilityMultiplier");
- cir.setReturnValue(newDurability);
- }
- }
+ @SuppressWarnings("ConstantConditions")
+ @Inject(method = "getMaxDamage", at = @At("RETURN"), cancellable = true)
+ private void durabilityMultiplier(CallbackInfoReturnable cir) {
+ if (this.hasNbt() && this.getNbt().contains("DurabilityMultiplier")) {
+ int newDurability = cir.getReturnValue();
+ newDurability *= this.getNbt().getFloat("DurabilityMultiplier");
+ cir.setReturnValue(newDurability);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java
index 545f287a..82b0fd20 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java
@@ -1,22 +1,22 @@
package com.github.platymemo.alaskanativecraft.mixin;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.Constant;
+import org.spongepowered.asm.mixin.injection.ModifyConstant;
+
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.PathAwareEntity;
import net.minecraft.world.World;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.Constant;
-import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(PathAwareEntity.class)
public abstract class LeadLengthMixin extends MobEntity {
+ protected LeadLengthMixin(EntityType extends MobEntity> entityType, World world) {
+ super(entityType, world);
+ }
- protected LeadLengthMixin(EntityType extends MobEntity> entityType, World world) {
- super(entityType, world);
- }
-
- @ModifyConstant(method = "updateLeash", constant = @Constant(floatValue = 10.0F))
- private float maxLeadLength(float maxLength) {
- return 48.0F;
- }
-}
\ No newline at end of file
+ @ModifyConstant(method = "updateLeash", constant = @Constant(floatValue = 10.0F))
+ private float maxLeadLength(float maxLength) {
+ return 48.0F;
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java
index 28869e91..f63af2b5 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java
@@ -1,8 +1,20 @@
package com.github.platymemo.alaskanativecraft.mixin;
+import java.util.Map;
+import java.util.UUID;
+
import com.github.platymemo.alaskanativecraft.entity.effect.AlaskaEffects;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.Unique;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
@@ -15,84 +27,74 @@
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.random.Random;
+import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.World;
-import org.spongepowered.asm.mixin.Final;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.Unique;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
-
-import java.util.Map;
-import java.util.UUID;
@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin extends Entity {
- @Unique
- private static final UUID SNOWSHOE_SPEED_BOOST_ID = UUID.fromString("0b824742-8bbc-4043-8caf-f997a543495f");
-
- protected LivingEntityMixin(EntityType> type, World world) {
- super(type, world);
- throw new AssertionError("wut");
- }
+ @Unique
+ private static final UUID SNOWSHOE_SPEED_BOOST_ID = UUID.fromString("0b824742-8bbc-4043-8caf-f997a543495f");
+ @Shadow
+ @Final
+ private Map activeStatusEffects;
- @Shadow
- public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute genericMovementSpeed);
+ protected LivingEntityMixin(EntityType> type, World world) {
+ super(type, world);
+ throw new AssertionError("wut");
+ }
- @Shadow
- public abstract ItemStack getEquippedStack(EquipmentSlot feet);
+ @Shadow
+ public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute genericMovementSpeed);
- @Shadow
- public abstract Random getRandom();
+ @Shadow
+ public abstract ItemStack getEquippedStack(EquipmentSlot feet);
- @Shadow @Final private Map activeStatusEffects;
+ @Shadow
+ public abstract RandomGenerator getRandom();
- @Inject(method = "removeSoulSpeedBoost", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
- protected void removeSnowshoeSpeedBoost(CallbackInfo ci, EntityAttributeInstance entityAttributeInstance) {
- if (entityAttributeInstance != null && entityAttributeInstance.getModifier(SNOWSHOE_SPEED_BOOST_ID) != null) {
- entityAttributeInstance.removeModifier(SNOWSHOE_SPEED_BOOST_ID);
- }
- }
+ @Inject(method = "removeSoulSpeedBoost", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
+ protected void removeSnowshoeSpeedBoost(CallbackInfo ci, EntityAttributeInstance entityAttributeInstance) {
+ if (entityAttributeInstance != null && entityAttributeInstance.getModifier(SNOWSHOE_SPEED_BOOST_ID) != null) {
+ entityAttributeInstance.removeModifier(SNOWSHOE_SPEED_BOOST_ID);
+ }
+ }
- @Inject(method = "addSoulSpeedBoostIfNeeded", at = @At("TAIL"))
- protected void addSnowshoeSpeedBoostIfNeeded(CallbackInfo ci) {
- if (!this.getLandingBlockState().isAir()) {
- if (this.getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.SNOWSHOES) && this.isOnSnowshoeSpeedBlock()) {
- EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
- if (entityAttributeInstance == null) {
- return;
- }
+ @Inject(method = "addSoulSpeedBoostIfNeeded", at = @At("TAIL"))
+ protected void addSnowshoeSpeedBoostIfNeeded(CallbackInfo ci) {
+ if (!this.getLandingBlockState().isAir()) {
+ if (this.getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.SNOWSHOES) && this.isOnSnowshoeSpeedBlock()) {
+ EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
+ if (entityAttributeInstance == null) {
+ return;
+ }
- entityAttributeInstance.addTemporaryModifier(new EntityAttributeModifier(SNOWSHOE_SPEED_BOOST_ID, "Snowshoe speed boost", 0.025F, EntityAttributeModifier.Operation.ADDITION));
- if (this.getRandom().nextFloat() < 0.01F) {
- ItemStack itemStack = this.getEquippedStack(EquipmentSlot.FEET);
- itemStack.damage(1, (LivingEntity) (Object) this, player -> player.sendEquipmentBreakStatus(EquipmentSlot.FEET));
- }
- }
- }
- }
+ entityAttributeInstance.addTemporaryModifier(new EntityAttributeModifier(SNOWSHOE_SPEED_BOOST_ID, "Snowshoe speed boost", 0.025F, EntityAttributeModifier.Operation.ADDITION));
+ if (this.getRandom().nextFloat() < 0.01F) {
+ ItemStack itemStack = this.getEquippedStack(EquipmentSlot.FEET);
+ itemStack.damage(1, (LivingEntity) (Object) this, player -> player.sendEquipmentBreakStatus(EquipmentSlot.FEET));
+ }
+ }
+ }
+ }
- @Unique
- protected boolean isOnSnowshoeSpeedBlock() {
- BlockPos pos = this.getVelocityAffectingPos();
- return this.world.getBlockState(pos).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS) || this.world.getBlockState(pos.up()).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS);
- }
+ @Unique
+ protected boolean isOnSnowshoeSpeedBlock() {
+ BlockPos pos = this.getVelocityAffectingPos();
+ return this.world.getBlockState(pos).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS) || this.world.getBlockState(pos.up()).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS);
+ }
- /*
- * We have to tick the medicinal effect before all the others because we modify the list of active effects
- */
- @Inject(method = "tickStatusEffects", at = @At("HEAD"))
- private void tickMedicinalEffect(CallbackInfo ci) {
- if (this.activeStatusEffects.containsKey(AlaskaEffects.MEDICINAL)) {
- var statusEffect = this.activeStatusEffects.get(AlaskaEffects.MEDICINAL);
- var duration = statusEffect.getDuration();
- var amplifier = statusEffect.getAmplifier();
- if (duration % (80 >> amplifier) == 0) {
- statusEffect.getEffectType().applyUpdateEffect((LivingEntity) (Object) this, amplifier);
- }
- }
- }
+ /*
+ * We have to tick the medicinal effect before all the others because we modify the list of active effects
+ */
+ @Inject(method = "tickStatusEffects", at = @At("HEAD"))
+ private void tickMedicinalEffect(CallbackInfo ci) {
+ if (this.activeStatusEffects.containsKey(AlaskaEffects.MEDICINAL)) {
+ var statusEffect = this.activeStatusEffects.get(AlaskaEffects.MEDICINAL);
+ var duration = statusEffect.getDuration();
+ var amplifier = statusEffect.getAmplifier();
+ if (duration % (80 >> amplifier) == 0) {
+ statusEffect.getEffectType().applyUpdateEffect((LivingEntity) (Object) this, amplifier);
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java
index a401af14..37af8a36 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java
@@ -1,11 +1,12 @@
package com.github.platymemo.alaskanativecraft.mixin;
-import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
+import net.minecraft.entity.ai.goal.MeleeAttackGoal;
+
@Mixin(MeleeAttackGoal.class)
public interface MeleeAttackGoalAccessor {
- @Accessor("cooldown")
- void setCooldown(int cooldown);
+ @Accessor("cooldown")
+ void setCooldown(int cooldown);
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java
index e0e8ddd8..78df4084 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java
@@ -1,6 +1,12 @@
package com.github.platymemo.alaskanativecraft.mixin;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
@@ -8,29 +14,23 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin extends LivingEntity {
+ protected PlayerEntityMixin(EntityType extends LivingEntity> entityType, World world) {
+ super(entityType, world);
+ throw new AssertionError("wut");
+ }
- protected PlayerEntityMixin(EntityType extends LivingEntity> entityType, World world) {
- super(entityType, world);
- throw new AssertionError("wut");
- }
-
- @Override
- @Shadow
- public abstract ItemStack getEquippedStack(EquipmentSlot slot);
+ @Override
+ @Shadow
+ public abstract ItemStack getEquippedStack(EquipmentSlot slot);
- @Inject(at = @At("HEAD"), method = "updateTurtleHelmet")
- private void updateSnowGoggles(CallbackInfo ci) {
- ItemStack stack = this.getEquippedStack(EquipmentSlot.HEAD);
- if (stack.isOf(AlaskaItems.SNOW_GOGGLES)) {
- this.removeStatusEffect(StatusEffects.BLINDNESS);
- }
- }
+ @Inject(at = @At("HEAD"), method = "updateTurtleHelmet")
+ private void updateSnowGoggles(CallbackInfo ci) {
+ ItemStack stack = this.getEquippedStack(EquipmentSlot.HEAD);
+ if (stack.isOf(AlaskaItems.SNOW_GOGGLES)) {
+ this.removeStatusEffect(StatusEffects.BLINDNESS);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java
index ae684952..9c562785 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java
@@ -1,26 +1,26 @@
package com.github.platymemo.alaskanativecraft.mixin;
import com.github.platymemo.alaskanativecraft.entity.SealEntity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
import net.minecraft.entity.EntityType;
-import net.minecraft.entity.ai.goal.ActiveTargetGoal;
+import net.minecraft.entity.ai.goal.TargetGoal;
import net.minecraft.entity.mob.Angerable;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.PolarBearEntity;
import net.minecraft.world.World;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PolarBearEntity.class)
public abstract class PolarBearMixin extends AnimalEntity implements Angerable {
+ protected PolarBearMixin(EntityType extends AnimalEntity> type, World world) {
+ super(type, world);
+ }
- protected PolarBearMixin(EntityType extends AnimalEntity> type, World world) {
- super(type, world);
- }
-
- @Inject(at = @At("TAIL"), method = "initGoals()V")
- private void addSealTarget(CallbackInfo ci) {
- targetSelector.add(3, new ActiveTargetGoal<>(this, SealEntity.class, true));
- }
+ @Inject(at = @At("TAIL"), method = "initGoals()V")
+ private void addSealTarget(CallbackInfo ci) {
+ targetSelector.add(3, new TargetGoal<>(this, SealEntity.class, true));
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java
index 4e7db9e9..6bff3ffc 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java
@@ -1,25 +1,27 @@
package com.github.platymemo.alaskanativecraft.mixin;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
-import net.minecraft.block.PowderSnowBlock;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EquipmentSlot;
-import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import net.minecraft.block.PowderSnowBlock;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EquipmentSlot;
+import net.minecraft.entity.LivingEntity;
+
@Mixin(PowderSnowBlock.class)
public class PowderSnowBlockMixin {
- @Inject(method = "canWalkOnPowderSnow", at = @At(value = "RETURN", ordinal = 1), cancellable = true)
- private static void isWearingSnowshoesOrMukluks(Entity entity, CallbackInfoReturnable cir) {
- if (entity instanceof LivingEntity livingEntity) {
- var stack = livingEntity.getEquippedStack(EquipmentSlot.FEET);
- cir.setReturnValue(stack.isOf(AlaskaItems.SNOWSHOES) || stack.isOf(AlaskaItems.MUKLUKS));
- return;
- }
- // Prevents leather boots from allowing snow walking
- cir.setReturnValue(false);
- }
+ @Inject(method = "canWalkOnPowderSnow", at = @At(value = "RETURN", ordinal = 1), cancellable = true)
+ private static void isWearingSnowshoesOrMukluks(Entity entity, CallbackInfoReturnable cir) {
+ if (entity instanceof LivingEntity livingEntity) {
+ var stack = livingEntity.getEquippedStack(EquipmentSlot.FEET);
+ cir.setReturnValue(stack.isOf(AlaskaItems.SNOWSHOES) || stack.isOf(AlaskaItems.MUKLUKS));
+ return;
+ }
+
+ // Prevents leather boots from allowing snow walking
+ cir.setReturnValue(false);
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java
index 2ebec7a8..a747a5d8 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java
@@ -1,9 +1,7 @@
package com.github.platymemo.alaskanativecraft.mixin;
-import net.minecraft.inventory.CraftingInventory;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.recipe.RepairItemRecipe;
+import java.util.List;
+
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
@@ -13,29 +11,31 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
-import java.util.List;
+import net.minecraft.inventory.CraftingInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.recipe.RepairItemRecipe;
@Mixin(RepairItemRecipe.class)
public abstract class RepairItemRecipeMixin {
+ @Unique
+ private ItemStack anc$cachedStack;
- @Unique
- private ItemStack anc$cachedStack;
-
- @Inject(method = "craft", at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;"), locals = LocalCapture.CAPTURE_FAILHARD)
- private void cacheItemStack(CraftingInventory craftingInventory, CallbackInfoReturnable cir, @NotNull List list) {
- this.anc$cachedStack = list.get(0);
- }
+ @Inject(method = "craft(Lnet/minecraft/inventory/CraftingInventory;)Lnet/minecraft/item/ItemStack;", at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;"), locals = LocalCapture.CAPTURE_FAILHARD)
+ private void cacheItemStack(CraftingInventory craftingInventory, CallbackInfoReturnable cir, @NotNull List list) {
+ this.anc$cachedStack = list.get(0);
+ }
- @Redirect(method = "craft", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I"))
- private int redirectGetMaxDamage(Item item) {
- return this.anc$cachedStack.getMaxDamage();
- }
+ @Redirect(method = "craft(Lnet/minecraft/inventory/CraftingInventory;)Lnet/minecraft/item/ItemStack;", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I"))
+ private int redirectGetMaxDamage(Item item) {
+ return this.anc$cachedStack.getMaxDamage();
+ }
- @SuppressWarnings("ConstantConditions")
- @Inject(method = "craft", at = @At("RETURN"))
- private void addDurabilityMultiplier(CraftingInventory craftingInventory, @NotNull CallbackInfoReturnable cir) {
- if (!cir.getReturnValue().isEmpty() && anc$cachedStack.hasNbt() && anc$cachedStack.getNbt().contains("DurabilityMultiplier")) {
- cir.getReturnValue().getOrCreateNbt().putFloat("DurabilityMultiplier", anc$cachedStack.getNbt().getFloat("DurabilityMultiplier"));
- }
- }
+ @SuppressWarnings("ConstantConditions")
+ @Inject(method = "craft(Lnet/minecraft/inventory/CraftingInventory;)Lnet/minecraft/item/ItemStack;", at = @At("RETURN"))
+ private void addDurabilityMultiplier(CraftingInventory craftingInventory, @NotNull CallbackInfoReturnable cir) {
+ if (!cir.getReturnValue().isEmpty() && this.anc$cachedStack.hasNbt() && this.anc$cachedStack.getNbt().contains("DurabilityMultiplier")) {
+ cir.getReturnValue().getOrCreateNbt().putFloat("DurabilityMultiplier", this.anc$cachedStack.getNbt().getFloat("DurabilityMultiplier"));
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java
index 7a9cf624..d3d30c5a 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java
@@ -1,10 +1,8 @@
package com.github.platymemo.alaskanativecraft.mixin;
+import java.util.Set;
+
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
-import net.minecraft.inventory.CraftingInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NbtCompound;
-import net.minecraft.recipe.ShapedRecipe;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -13,32 +11,36 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.util.Set;
+import net.minecraft.inventory.CraftingInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.recipe.ShapedRecipe;
@Mixin(ShapedRecipe.class)
public class ShapedRecipeMixin {
- @Shadow
- @Final
- ItemStack output;
+ @Shadow
+ @Final
+ ItemStack output;
+
+ @Inject(at = @At("RETURN"), method = "craft*", cancellable = true)
+ private void addDurability(@NotNull CraftingInventory craftingInventory, CallbackInfoReturnable cir) {
+ if (craftingInventory.containsAny(Set.of(AlaskaItems.DRIFTWOOD_CHUNK, AlaskaItems.ANTLER, AlaskaItems.IVORY)) && this.output.getItem().isDamageable()) {
+ ItemStack protectedItem = this.output.copy();
+ NbtCompound tag = protectedItem.getOrCreateNbt();
+ float durabilityMultiplier = 1;
+ for (int i = 0; i < craftingInventory.size(); ++i) {
+ ItemStack stack = craftingInventory.getStack(i);
+ if (stack.isOf(AlaskaItems.DRIFTWOOD_CHUNK)) {
+ durabilityMultiplier *= 1.05;
+ } else if (stack.isOf(AlaskaItems.ANTLER)) {
+ durabilityMultiplier *= 1.2;
+ } else if (stack.isOf(AlaskaItems.IVORY)) {
+ durabilityMultiplier *= 1.4;
+ }
+ }
- @Inject(at = @At("RETURN"), method = "craft*", cancellable = true)
- private void addDurability(@NotNull CraftingInventory craftingInventory, CallbackInfoReturnable cir) {
- if (craftingInventory.containsAny(Set.of(AlaskaItems.DRIFTWOOD_CHUNK, AlaskaItems.ANTLER, AlaskaItems.IVORY)) && this.output.getItem().isDamageable()) {
- ItemStack protectedItem = this.output.copy();
- NbtCompound tag = protectedItem.getOrCreateNbt();
- float durabilityMultiplier = 1;
- for (int i = 0; i < craftingInventory.size(); ++i) {
- ItemStack stack = craftingInventory.getStack(i);
- if (stack.isOf(AlaskaItems.DRIFTWOOD_CHUNK)) {
- durabilityMultiplier *= 1.05;
- } else if (stack.isOf(AlaskaItems.ANTLER)) {
- durabilityMultiplier *= 1.2;
- } else if (stack.isOf(AlaskaItems.IVORY)) {
- durabilityMultiplier *= 1.4;
- }
- }
- tag.putFloat("DurabilityMultiplier", durabilityMultiplier);
- cir.setReturnValue(protectedItem);
- }
- }
+ tag.putFloat("DurabilityMultiplier", durabilityMultiplier);
+ cir.setReturnValue(protectedItem);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java
index 38c5c629..b8ca6340 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java
@@ -3,6 +3,11 @@
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.ChickenEntity;
@@ -13,43 +18,38 @@
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.EntityHitResult;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(SnowballEntity.class)
public class SnowballEntityMixin {
- @Inject(at = @At("TAIL"), method = "onEntityHit")
- private void makeThatBirbAPtarmigan(EntityHitResult entityHitResult, CallbackInfo ci) {
- if (AlaskaConfig.getConfig().snowballConversion) {
- Entity entity = entityHitResult.getEntity();
- if ((entity instanceof ParrotEntity && !(entity instanceof PtarmiganEntity)) || entity instanceof ChickenEntity) {
-
- Identifier ptarmigan = new Identifier(AlaskaNativeCraft.MOD_ID, "ptarmigan");
-
- Text entityName = null;
- if (entity.hasCustomName()) {
- entityName = entity.getCustomName();
- }
-
- NbtCompound entityTag = new NbtCompound();
- entityTag.putString("id", ptarmigan.toString());
-
- if (entity.getEntityWorld() instanceof ServerWorld world) {
- Entity newEntity = EntityType.loadEntityWithPassengers(entityTag, world, (entityMaker) -> {
- entityMaker.refreshPositionAndAngles(entity.getX(), entity.getY(), entity.getZ(), entityMaker.getYaw(), entityMaker.getPitch());
- return entityMaker;
- });
- if (newEntity != null) {
- newEntity.setCustomName(entityName);
- }
-
- if (world.spawnNewEntityAndPassengers(newEntity)) {
- entity.discard();
- }
- }
- }
- }
- }
+ @Inject(at = @At("TAIL"), method = "onEntityHit")
+ private void makeThatBirbAPtarmigan(EntityHitResult entityHitResult, CallbackInfo ci) {
+ if (AlaskaConfig.getConfig().snowballConversion) {
+ Entity entity = entityHitResult.getEntity();
+ if ((entity instanceof ParrotEntity && !(entity instanceof PtarmiganEntity)) || entity instanceof ChickenEntity) {
+ Identifier ptarmigan = new Identifier(AlaskaNativeCraft.MOD_ID, "ptarmigan");
+
+ Text entityName = null;
+ if (entity.hasCustomName()) {
+ entityName = entity.getCustomName();
+ }
+
+ NbtCompound entityTag = new NbtCompound();
+ entityTag.putString("id", ptarmigan.toString());
+
+ if (entity.getWorld() instanceof ServerWorld world) {
+ Entity newEntity = EntityType.loadEntityWithPassengers(entityTag, world, (entityMaker) -> {
+ entityMaker.refreshPositionAndAngles(entity.getX(), entity.getY(), entity.getZ(), entityMaker.getYaw(), entityMaker.getPitch());
+ return entityMaker;
+ });
+
+ if (newEntity != null) {
+ newEntity.setCustomName(entityName);
+ }
+
+ world.spawnEntityAndPassengers(newEntity);
+ entity.discard();
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java
index ba3ec62a..9192d832 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java
@@ -4,12 +4,6 @@
import com.mojang.authlib.GameProfile;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.input.Input;
-import net.minecraft.client.network.ClientPlayerEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.network.encryption.PlayerPublicKey;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -17,25 +11,31 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import net.minecraft.client.input.Input;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.network.encryption.PlayerPublicKey;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+
@Environment(EnvType.CLIENT)
@Mixin(ClientPlayerEntity.class)
public abstract class ClientPlayerEntityMixin extends PlayerEntity {
- @Shadow
- public Input input;
- @Shadow
- private boolean riding;
-
- ClientPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) {
- super(world, pos, yaw, gameProfile, publicKey);
- throw new AssertionError("Mixin constructor called, something is very wrong!");
- }
+ @Shadow
+ public Input input;
+ @Shadow
+ private boolean riding;
+ ClientPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) {
+ super(world, pos, yaw, gameProfile, publicKey);
+ throw new AssertionError("Mixin constructor called, something is very wrong!");
+ }
- @Inject(at = @At("TAIL"), method = "tickRiding()V")
- private void rideDogsled(CallbackInfo ci) {
- if (this.getVehicle() instanceof DogsledEntity dogsledEntity) {
- dogsledEntity.setInputs(this.input.pressingLeft, this.input.pressingRight, this.input.pressingForward, this.input.pressingBack);
- this.riding |= this.input.pressingLeft || this.input.pressingRight || this.input.pressingForward || this.input.pressingBack;
- }
- }
+ @Inject(at = @At("TAIL"), method = "tickRiding()V")
+ private void rideDogsled(CallbackInfo ci) {
+ if (this.getVehicle() instanceof DogsledEntity dogsledEntity) {
+ dogsledEntity.setInputs(this.input.pressingLeft, this.input.pressingRight, this.input.pressingForward, this.input.pressingBack);
+ this.riding |= this.input.pressingLeft || this.input.pressingRight || this.input.pressingForward || this.input.pressingBack;
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java
index 39cc1ae0..c108c7a8 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java
@@ -3,22 +3,23 @@
import com.github.platymemo.alaskanativecraft.recipe.AlaskaRecipes;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.recipebook.ClientRecipeBook;
-import net.minecraft.client.recipebook.RecipeBookGroup;
-import net.minecraft.recipe.Recipe;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import net.minecraft.client.recipebook.ClientRecipeBook;
+import net.minecraft.client.recipebook.RecipeBookGroup;
+import net.minecraft.recipe.Recipe;
+
@Environment(EnvType.CLIENT)
@Mixin(ClientRecipeBook.class)
public class ClientRecipeBookMixin {
- @Inject(method = "getGroupForRecipe(Lnet/minecraft/recipe/Recipe;)Lnet/minecraft/client/recipebook/RecipeBookGroup;", at = @At("HEAD"), cancellable = true)
- private static void removeDryingRecipe(@NotNull Recipe> recipe, CallbackInfoReturnable cir) {
- if (recipe.getType() == AlaskaRecipes.DRYING) {
- cir.setReturnValue(RecipeBookGroup.UNKNOWN);
- }
- }
+ @Inject(method = "getGroupForRecipe(Lnet/minecraft/recipe/Recipe;)Lnet/minecraft/client/recipebook/RecipeBookGroup;", at = @At("HEAD"), cancellable = true)
+ private static void removeDryingRecipe(@NotNull Recipe> recipe, CallbackInfoReturnable cir) {
+ if (recipe.getType() == AlaskaRecipes.DRYING) {
+ cir.setReturnValue(RecipeBookGroup.UNKNOWN);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java
index fa035a0f..10c89d90 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java
@@ -4,10 +4,6 @@
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.hud.InGameHud;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.util.Identifier;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -16,23 +12,28 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.hud.InGameHud;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.util.Identifier;
+
@Environment(EnvType.CLIENT)
@Mixin(InGameHud.class)
public abstract class InGameHudMixin {
- private static final Identifier SNOWGOOGLES_BLUR = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/misc/gogglesblur.png");
+ private static final Identifier SNOWGOOGLES_BLUR = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/misc/gogglesblur.png");
- @Shadow
- @Final
- private MinecraftClient client;
+ @Shadow
+ @Final
+ private MinecraftClient client;
- @Shadow
- protected abstract void renderOverlay(Identifier texture, float opacity);
+ @Shadow
+ protected abstract void renderOverlay(Identifier texture, float opacity);
- @SuppressWarnings("ConstantConditions")
- @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 1), method = "render")
- private void renderSnowGogglesOverlay(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
- if (this.client.options.getPerspective().isFirstPerson() && this.client.player.getInventory().getArmorStack(3).getItem() == AlaskaItems.SNOW_GOGGLES) {
- this.renderOverlay(SNOWGOOGLES_BLUR, 1.0F);
- }
- }
+ @SuppressWarnings("ConstantConditions")
+ @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 1), method = "render")
+ private void renderSnowGogglesOverlay(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
+ if (this.client.options.getPerspective().isFirstPerson() && this.client.player.getInventory().getArmorStack(3).getItem() == AlaskaItems.SNOW_GOGGLES) {
+ this.renderOverlay(SNOWGOOGLES_BLUR, 1.0F);
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java
index 999bc165..20f91350 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java
@@ -6,6 +6,12 @@
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.jetbrains.annotations.NotNull;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
@@ -15,33 +21,26 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Environment(EnvType.CLIENT)
@Mixin(ItemRenderer.class)
public class ItemRendererMixin {
+ @Inject(at = @At("HEAD"),
+ method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V",
+ cancellable = true)
+ public void renderHarpoons(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int k, CallbackInfo ci) {
+ BakedModel model = MinecraftClient.getInstance().getItemRenderer().getHeldItemModel(stack, world, entity, k);
+ if (stack.isIn(AlaskaTags.HARPOONS) && HarpoonItemRenderer.INSTANCE.render(entity, stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) {
+ ci.cancel();
+ }
+ }
- @Inject(at = @At("HEAD"),
- method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V",
- cancellable = true)
- public void renderHarpoons(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int k, CallbackInfo ci) {
- BakedModel model = MinecraftClient.getInstance().getItemRenderer().getModel(stack, world, entity, k);
- if (stack.isIn(AlaskaTags.HARPOONS) && HarpoonItemRenderer.INSTANCE.render(entity, stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) {
- ci.cancel();
- }
- }
-
- @Inject(at = @At("HEAD"),
- method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V",
- cancellable = true)
- public void renderSnowshoes(@NotNull ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) {
- if (stack.isOf(AlaskaItems.SNOWSHOES) && SnowshoeItemRenderer.INSTANCE.render(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) {
- ci.cancel();
- }
- }
-
-}
\ No newline at end of file
+ @Inject(at = @At("HEAD"),
+ method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V",
+ cancellable = true)
+ public void renderSnowshoes(@NotNull ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) {
+ if (stack.isOf(AlaskaItems.SNOWSHOES) && SnowshoeItemRenderer.INSTANCE.render(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) {
+ ci.cancel();
+ }
+ }
+}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java
index 99cb7e1d..2098f4d2 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java
@@ -3,6 +3,11 @@
import com.github.platymemo.alaskanativecraft.entity.DogsledEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.objectweb.asm.Opcodes;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.ModifyVariable;
+
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
@@ -13,40 +18,37 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.WolfEntity;
import net.minecraft.util.math.MathHelper;
-import org.objectweb.asm.Opcodes;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Environment(EnvType.CLIENT)
@Mixin(LivingEntityRenderer.class)
public abstract class LivingEntityRendererMixin> extends EntityRenderer implements FeatureRendererContext {
+ protected LivingEntityRendererMixin(EntityRendererFactory.Context context) {
+ super(context);
+ }
+
+ @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0),
+ method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
+ ordinal = 7)
+ private float changeLimbDistance(float limbDistance, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
+ if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) {
+ limbDistance = MathHelper.lerp(g, livingEntity.lastLimbDistance, livingEntity.limbDistance);
+
+ if (limbDistance > 1.0F) {
+ limbDistance = 1.0F;
+ }
+ }
+
+ return limbDistance;
+ }
+
+ @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0),
+ method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
+ ordinal = 8)
+ private float changeLimbAngle(float limbAngle, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
+ if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) {
+ limbAngle = livingEntity.limbAngle - livingEntity.limbDistance * (1.0F - g);
+ }
- protected LivingEntityRendererMixin(EntityRendererFactory.Context context) {
- super(context);
- }
-
- @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0),
- method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
- ordinal = 7)
- private float changeLimbDistance(float limbDistance, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
- if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) {
- limbDistance = MathHelper.lerp(g, livingEntity.lastLimbDistance, livingEntity.limbDistance);
-
- if (limbDistance > 1.0F) {
- limbDistance = 1.0F;
- }
- }
- return limbDistance;
- }
-
- @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0),
- method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
- ordinal = 8)
- private float changeLimbAngle(float limbAngle, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
- if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) {
- limbAngle = livingEntity.limbAngle - livingEntity.limbDistance * (1.0F - g);
- }
- return limbAngle;
- }
+ return limbAngle;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java
index b8fc6c17..66f7d7f6 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java
@@ -3,6 +3,12 @@
import com.github.platymemo.alaskanativecraft.entity.DogsledEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
@@ -12,47 +18,42 @@
import net.minecraft.util.Hand;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Environment(EnvType.CLIENT)
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
-
- @Shadow
- public HitResult crosshairTarget;
-
- @Shadow
- public ClientPlayerEntity player;
-
- @Shadow
- public ClientPlayerInteractionManager interactionManager;
-
- @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/hit/EntityHitResult;getEntity()Lnet/minecraft/entity/Entity;", ordinal = 0),
- method = "doItemPick",
- cancellable = true)
- private void pickDogsledItem(CallbackInfo ci) {
- Entity entity = ((EntityHitResult) this.crosshairTarget).getEntity();
-
- if (entity instanceof DogsledEntity) {
- ItemStack pickedDogsled = new ItemStack(((DogsledEntity) entity).asItem());
- PlayerInventory playerInventory = this.player.getInventory();
-
- int i = playerInventory.getSlotWithStack(pickedDogsled);
- if (this.player.getAbilities().creativeMode) {
- playerInventory.addPickBlock(pickedDogsled);
- this.interactionManager.clickCreativeStack(this.player.getStackInHand(Hand.MAIN_HAND), 36 + playerInventory.selectedSlot);
- } else if (i != -1) {
- if (PlayerInventory.isValidHotbarIndex(i)) {
- playerInventory.selectedSlot = i;
- } else {
- this.interactionManager.pickFromInventory(i);
- }
- }
- ci.cancel();
- }
- }
+ @Shadow
+ public HitResult crosshairTarget;
+
+ @Shadow
+ public ClientPlayerEntity player;
+
+ @Shadow
+ public ClientPlayerInteractionManager interactionManager;
+
+ @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/hit/EntityHitResult;getEntity()Lnet/minecraft/entity/Entity;", ordinal = 0),
+ method = "doItemPick",
+ cancellable = true)
+ private void pickDogsledItem(CallbackInfo ci) {
+ Entity entity = ((EntityHitResult) this.crosshairTarget).getEntity();
+
+ if (entity instanceof DogsledEntity) {
+ ItemStack pickedDogsled = new ItemStack(((DogsledEntity) entity).asItem());
+ PlayerInventory playerInventory = this.player.getInventory();
+
+ int i = playerInventory.getSlotWithStack(pickedDogsled);
+ if (this.player.getAbilities().creativeMode) {
+ playerInventory.addPickBlock(pickedDogsled);
+ this.interactionManager.clickCreativeStack(this.player.getStackInHand(Hand.MAIN_HAND), 36 + playerInventory.selectedSlot);
+ } else if (i != -1) {
+ if (PlayerInventory.isValidHotbarIndex(i)) {
+ playerInventory.selectedSlot = i;
+ } else {
+ this.interactionManager.pickFromInventory(i);
+ }
+ }
+
+ ci.cancel();
+ }
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java
index c933344b..6fb4dbab 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java
@@ -1,8 +1,12 @@
package com.github.platymemo.alaskanativecraft.recipe;
+import java.util.Random;
+
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
import com.google.common.collect.ImmutableList;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.inventory.CraftingInventory;
@@ -15,118 +19,115 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Random;
public class AkutaqRecipe extends SpecialCraftingRecipe {
- private static final ImmutableList> POSSIBLE_EFFECTS = ImmutableList.of(
- new Pair<>(StatusEffects.ABSORPTION, 20),
- new Pair<>(StatusEffects.REGENERATION, 10),
- new Pair<>(StatusEffects.RESISTANCE, 10),
- new Pair<>(StatusEffects.FIRE_RESISTANCE, 10),
- new Pair<>(StatusEffects.HASTE, 10),
- new Pair<>(StatusEffects.STRENGTH, 5),
- new Pair<>(StatusEffects.SPEED, 12),
- new Pair<>(StatusEffects.JUMP_BOOST, 10),
- new Pair<>(StatusEffects.SATURATION, 10)
- );
-
- public AkutaqRecipe(Identifier id) {
- super(id);
- }
-
- // Can't use SuspiciousStewItem.addEffectToStew because it overwrites the list tag each time
- public static void addEffectToAkutaq(@NotNull ItemStack stew, StatusEffect effect, int duration) {
- NbtCompound compoundTag = stew.getOrCreateNbt();
- NbtList listTag = compoundTag.getList("Effects", 10);
-
- boolean effectExists = false;
-
- byte effectId = (byte) StatusEffect.getRawId(effect);
- int actualDuration = duration;
- for (int i = 0; i < listTag.size(); ++i) {
- NbtCompound previousEffect = listTag.getCompound(i);
- if (previousEffect.contains("EffectDuration", 3) && effectId == previousEffect.getByte("EffectId")) {
- actualDuration += previousEffect.getInt("EffectDuration");
- previousEffect.putInt("EffectDuration", actualDuration);
- effectExists = true;
- }
- }
-
- if (!effectExists) {
- NbtCompound newEffect = new NbtCompound();
- newEffect.putByte("EffectId", effectId);
- newEffect.putInt("EffectDuration", actualDuration);
- listTag.add(newEffect);
- }
-
- compoundTag.put("Effects", listTag);
- }
-
- @Override
- public boolean matches(@NotNull CraftingInventory inv, World world) {
- boolean hasMeat = false;
- boolean hasBerries = false;
- boolean hasBowl = false;
-
- for (int i = 0; i < inv.size(); ++i) {
- ItemStack itemStack = inv.getStack(i);
- if (!itemStack.isEmpty()) {
-
- // Need at least 1 berry but can have more
- if (itemStack.isIn(AlaskaTags.AKUTAQ_BERRIES)) {
- hasBerries = true;
- }
- // Can only have one piece of meat
- else if (itemStack.isIn(AlaskaTags.AKUTAQ_MEATS) && !hasMeat) {
- hasMeat = true;
- } else {
-
- // Checks for bowl, if not a bowl or anything but a bowl, returns false
- if (itemStack.getItem() != Items.BOWL || hasBowl) {
- return false;
- }
-
- hasBowl = true;
- }
- }
- }
-
- return hasMeat && hasBerries && hasBowl;
- }
-
- @Override
- public ItemStack craft(@NotNull CraftingInventory inv) {
- ItemStack akutaq = new ItemStack(AlaskaItems.AKUTAQ, 1);
- Random random = new Random();
-
- ItemStack currentItemstack;
- for (int i = 0; i < inv.size(); ++i) {
- currentItemstack = inv.getStack(i);
- if (!currentItemstack.isEmpty() && currentItemstack.isIn(AlaskaTags.AKUTAQ_BERRIES)) {
- Pair pair = POSSIBLE_EFFECTS.get(random.nextInt(POSSIBLE_EFFECTS.size()));
- StatusEffect statusEffect = pair.getLeft();
- int duration = pair.getRight();
- if (!statusEffect.isInstant()) {
- duration *= 20;
- }
-
- // Add effect
- addEffectToAkutaq(akutaq, statusEffect, duration);
- }
- }
-
- return akutaq;
- }
-
- @Override
- public boolean fits(int width, int height) {
- return width >= 2 && height >= 2;
- }
-
- @Override
- public RecipeSerializer> getSerializer() {
- return AlaskaRecipes.AKUTAQ;
- }
+ private static final ImmutableList> POSSIBLE_EFFECTS = ImmutableList.of(
+ new Pair<>(StatusEffects.ABSORPTION, 20),
+ new Pair<>(StatusEffects.REGENERATION, 10),
+ new Pair<>(StatusEffects.RESISTANCE, 10),
+ new Pair<>(StatusEffects.FIRE_RESISTANCE, 10),
+ new Pair<>(StatusEffects.HASTE, 10),
+ new Pair<>(StatusEffects.STRENGTH, 5),
+ new Pair<>(StatusEffects.SPEED, 12),
+ new Pair<>(StatusEffects.JUMP_BOOST, 10),
+ new Pair<>(StatusEffects.SATURATION, 10)
+ );
+
+ public AkutaqRecipe(Identifier id) {
+ super(id);
+ }
+
+ // Can't use SuspiciousStewItem.addEffectToStew because it overwrites the list tag each time
+ public static void addEffectToAkutaq(@NotNull ItemStack stew, StatusEffect effect, int duration) {
+ NbtCompound compoundTag = stew.getOrCreateNbt();
+ NbtList listTag = compoundTag.getList("Effects", 10);
+
+ boolean effectExists = false;
+
+ byte effectId = (byte) StatusEffect.getRawId(effect);
+ int actualDuration = duration;
+ for (int i = 0; i < listTag.size(); ++i) {
+ NbtCompound previousEffect = listTag.getCompound(i);
+ if (previousEffect.contains("EffectDuration", 3) && effectId == previousEffect.getByte("EffectId")) {
+ actualDuration += previousEffect.getInt("EffectDuration");
+ previousEffect.putInt("EffectDuration", actualDuration);
+ effectExists = true;
+ }
+ }
+
+ if (!effectExists) {
+ NbtCompound newEffect = new NbtCompound();
+ newEffect.putByte("EffectId", effectId);
+ newEffect.putInt("EffectDuration", actualDuration);
+ listTag.add(newEffect);
+ }
+
+ compoundTag.put("Effects", listTag);
+ }
+
+ @Override
+ public boolean matches(@NotNull CraftingInventory inv, World world) {
+ boolean hasMeat = false;
+ boolean hasBerries = false;
+ boolean hasBowl = false;
+
+ for (int i = 0; i < inv.size(); ++i) {
+ ItemStack itemStack = inv.getStack(i);
+ if (!itemStack.isEmpty()) {
+ if (itemStack.isIn(AlaskaTags.AKUTAQ_BERRIES)) { // Need at least 1 berry but can have more
+ hasBerries = true;
+ } else if (itemStack.isIn(AlaskaTags.AKUTAQ_MEATS)) {
+ // Can only have one piece of meat
+ if (hasMeat) {
+ return false;
+ }
+
+ hasMeat = true;
+ } else {
+ // Checks for bowl, if not a bowl, or we've already found a bowl, returns false
+ if (itemStack.getItem() != Items.BOWL || hasBowl) {
+ return false;
+ }
+
+ hasBowl = true;
+ }
+ }
+ }
+
+ return hasMeat && hasBerries && hasBowl;
+ }
+
+ @Override
+ public ItemStack craft(@NotNull CraftingInventory inv) {
+ ItemStack akutaq = new ItemStack(AlaskaItems.AKUTAQ, 1);
+ Random random = new Random();
+
+ ItemStack currentItemstack;
+ for (int i = 0; i < inv.size(); ++i) {
+ currentItemstack = inv.getStack(i);
+ if (!currentItemstack.isEmpty() && currentItemstack.isIn(AlaskaTags.AKUTAQ_BERRIES)) {
+ Pair pair = POSSIBLE_EFFECTS.get(random.nextInt(POSSIBLE_EFFECTS.size()));
+ StatusEffect statusEffect = pair.getLeft();
+ int duration = pair.getRight();
+ if (!statusEffect.isInstant()) {
+ duration *= 20;
+ }
+
+ // Add effect
+ addEffectToAkutaq(akutaq, statusEffect, duration);
+ }
+ }
+
+ return akutaq;
+ }
+
+ @Override
+ public boolean fits(int width, int height) {
+ return width >= 2 && height >= 2;
+ }
+
+ @Override
+ public RecipeSerializer> getSerializer() {
+ return AlaskaRecipes.AKUTAQ;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java
index a5f9d39e..b253b355 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java
@@ -1,6 +1,7 @@
package com.github.platymemo.alaskanativecraft.recipe;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
+
import net.minecraft.recipe.CookingRecipeSerializer;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.SpecialRecipeSerializer;
@@ -8,17 +9,16 @@
import net.minecraft.util.registry.Registry;
public class AlaskaRecipes {
- public static final SpecialRecipeSerializer AKUTAQ = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_akutaq"), new SpecialRecipeSerializer<>(AkutaqRecipe::new));
- public static final SpecialRecipeSerializer FISH_STRIP = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_fish_strip"), new SpecialRecipeSerializer<>(FishStripRecipe::new));
-
- public static final RecipeType DRYING = Registry.register(Registry.RECIPE_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new RecipeType() {
- public String toString() {
- return "drying";
- }
- });
- public static final CookingRecipeSerializer DRYING_SERIALIZER = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new CookingRecipeSerializer<>(DryingRecipe::new, 1200));
+ public static final SpecialRecipeSerializer AKUTAQ = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_akutaq"), new SpecialRecipeSerializer<>(AkutaqRecipe::new));
+ public static final SpecialRecipeSerializer FISH_STRIP = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_fish_strip"), new SpecialRecipeSerializer<>(FishStripRecipe::new));
- public static void register() {
+ public static final RecipeType DRYING = Registry.register(Registry.RECIPE_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new RecipeType() {
+ public String toString() {
+ return "drying";
+ }
+ });
+ public static final CookingRecipeSerializer DRYING_SERIALIZER = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new CookingRecipeSerializer<>(DryingRecipe::new, 1200));
- }
+ public static void register() {
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java
index 10f8488e..63c9589d 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java
@@ -3,6 +3,7 @@
import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.AbstractCookingRecipe;
import net.minecraft.recipe.Ingredient;
@@ -10,18 +11,18 @@
import net.minecraft.util.Identifier;
public class DryingRecipe extends AbstractCookingRecipe {
- public DryingRecipe(Identifier id, String group, Ingredient input, ItemStack output, float experience, int cookTime) {
- super(AlaskaRecipes.DRYING, id, group, input, output, experience, cookTime);
- }
+ public DryingRecipe(Identifier id, String group, Ingredient input, ItemStack output, float experience, int cookTime) {
+ super(AlaskaRecipes.DRYING, id, group, input, output, experience, cookTime);
+ }
- @Override
- @Environment(EnvType.CLIENT)
- public ItemStack createIcon() {
- return new ItemStack(AlaskaBlocks.DRYING_RACK);
- }
+ @Override
+ @Environment(EnvType.CLIENT)
+ public ItemStack createIcon() {
+ return new ItemStack(AlaskaBlocks.DRYING_RACK);
+ }
- @Override
- public RecipeSerializer> getSerializer() {
- return AlaskaRecipes.DRYING_SERIALIZER;
- }
+ @Override
+ public RecipeSerializer> getSerializer() {
+ return AlaskaRecipes.DRYING_SERIALIZER;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java
index 6eb933ab..b77a4177 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java
@@ -2,83 +2,80 @@
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
+import org.jetbrains.annotations.NotNull;
+
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.SpecialCraftingRecipe;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
-import net.minecraft.util.math.random.Random;
+import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.World;
-import org.jetbrains.annotations.NotNull;
public class FishStripRecipe extends SpecialCraftingRecipe {
+ public FishStripRecipe(Identifier id) {
+ super(id);
+ }
- public FishStripRecipe(Identifier id) {
- super(id);
- }
-
- @Override
- public boolean matches(@NotNull CraftingInventory inv, World world) {
- boolean hasUlu = false;
- boolean hasFish = false;
+ @Override
+ public boolean matches(@NotNull CraftingInventory inv, World world) {
+ boolean hasUlu = false;
+ boolean hasFish = false;
- for (int i = 0; i < inv.size(); ++i) {
- ItemStack itemStack = inv.getStack(i);
- if (!itemStack.isEmpty()) {
+ for (int i = 0; i < inv.size(); ++i) {
+ ItemStack itemStack = inv.getStack(i);
+ if (!itemStack.isEmpty()) {
+ if (itemStack.isIn(AlaskaTags.SLICEABLE_FISH)) { // Need at least 1 fish but can have more
+ hasFish = true;
+ } else if (itemStack.isIn(AlaskaTags.ULUS) && !hasUlu) { // Can only have one ulu
+ hasUlu = true;
+ } else {
+ return false;
+ }
+ }
+ }
- // Need at least 1 fish but can have more
- if (itemStack.isIn(AlaskaTags.SLICEABLE_FISH)) {
- hasFish = true;
- }
- // Can only have one ulu
- else if (itemStack.isIn(AlaskaTags.ULUS) && !hasUlu) {
- hasUlu = true;
- } else {
- return false;
- }
- }
- }
+ return hasUlu && hasFish;
+ }
- return hasUlu && hasFish;
- }
+ @Override
+ public ItemStack craft(@NotNull CraftingInventory inv) {
+ int numOfFish = 0;
+ ItemStack stack;
+ for (int i = 0; i < inv.size(); ++i) {
+ stack = inv.getStack(i);
+ if (stack.isIn(AlaskaTags.SLICEABLE_FISH)) {
+ numOfFish++;
+ }
+ }
- @Override
- public ItemStack craft(@NotNull CraftingInventory inv) {
- int numOfFish = 0;
- ItemStack stack;
- for (int i = 0; i < inv.size(); ++i) {
- stack = inv.getStack(i);
- if (stack.isIn(AlaskaTags.SLICEABLE_FISH)) {
- numOfFish++;
- }
- }
- return new ItemStack(AlaskaItems.FISH_STRIP, numOfFish * 3);
- }
+ return new ItemStack(AlaskaItems.FISH_STRIP, numOfFish * 3);
+ }
- @Override
- public DefaultedList getRemainder(@NotNull CraftingInventory inventory) {
- DefaultedList defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY);
+ @Override
+ public DefaultedList getRemainder(@NotNull CraftingInventory inventory) {
+ DefaultedList defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY);
- for (int i = 0; i < defaultedList.size(); ++i) {
- ItemStack stack = inventory.getStack(i);
- if (stack.isIn(AlaskaTags.ULUS)) {
- if (!stack.damage(5, Random.create(), null)) {
- defaultedList.set(i, stack.copy());
- }
- }
- }
+ for (int i = 0; i < defaultedList.size(); ++i) {
+ ItemStack stack = inventory.getStack(i);
+ if (stack.isIn(AlaskaTags.ULUS)) {
+ if (!stack.damage(5, RandomGenerator.createLegacy(), null)) {
+ defaultedList.set(i, stack.copy());
+ }
+ }
+ }
- return defaultedList;
- }
+ return defaultedList;
+ }
- @Override
- public boolean fits(int width, int height) {
- return width * height >= 2;
- }
+ @Override
+ public boolean fits(int width, int height) {
+ return width * height >= 2;
+ }
- @Override
- public RecipeSerializer> getSerializer() {
- return AlaskaRecipes.FISH_STRIP;
- }
+ @Override
+ public RecipeSerializer> getSerializer() {
+ return AlaskaRecipes.FISH_STRIP;
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java b/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java
index ac1fc42f..687a115b 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java
@@ -1,29 +1,30 @@
package com.github.platymemo.alaskanativecraft.sound;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
+
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class AlaskaSoundEvents {
- public static final SoundEvent ENTITY_SEAL_AMBIENT;
- public static final SoundEvent ENTITY_SEAL_AMBIENT_BABY;
- public static final SoundEvent ENTITY_SEAL_HURT;
- public static final SoundEvent ENTITY_MOOSE_AMBIENT;
- public static final SoundEvent ENTITY_MOOSE_HURT;
+ public static final SoundEvent ENTITY_SEAL_AMBIENT;
+ public static final SoundEvent ENTITY_SEAL_AMBIENT_BABY;
+ public static final SoundEvent ENTITY_SEAL_HURT;
+ public static final SoundEvent ENTITY_MOOSE_AMBIENT;
+ public static final SoundEvent ENTITY_MOOSE_HURT;
- static {
- ENTITY_SEAL_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient"));
- ENTITY_SEAL_AMBIENT_BABY = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient.baby"));
- ENTITY_SEAL_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.hurt"));
- ENTITY_MOOSE_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.ambient"));
- ENTITY_MOOSE_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.hurt"));
- }
+ static {
+ ENTITY_SEAL_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient"));
+ ENTITY_SEAL_AMBIENT_BABY = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient.baby"));
+ ENTITY_SEAL_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.hurt"));
+ ENTITY_MOOSE_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.ambient"));
+ ENTITY_MOOSE_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.hurt"));
+ }
- private static SoundEvent register(Identifier id) {
- return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id));
- }
+ private static SoundEvent register(Identifier id) {
+ return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id));
+ }
- public static void register() {
- }
+ public static void register() {
+ }
}
diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java b/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java
index 4b3820a1..6d7ea542 100644
--- a/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java
+++ b/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java
@@ -2,6 +2,7 @@
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.tags.common.CommonBlockTags;
+
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.tag.TagKey;
@@ -10,27 +11,27 @@
import net.minecraft.world.biome.Biome;
public class AlaskaTags {
- public static final TagKey