mirror of
https://github.com/TeamMidnightDust/Puddles.git
synced 2025-12-15 11:35:09 +01:00
port: MC 1.21.4
This commit is contained in:
@@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version=1.21
|
||||
supported_versions=1.21.1
|
||||
yarn_mappings=1.21+build.9
|
||||
loader_version=0.15.11
|
||||
minecraft_version=1.21.4
|
||||
supported_versions=
|
||||
yarn_mappings=1.21.4+build.8
|
||||
loader_version=0.16.10
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 2.0.0
|
||||
mod_version = 2.0.1
|
||||
maven_group = eu.midnightdust
|
||||
archives_base_name = puddles
|
||||
release_type=release
|
||||
@@ -17,7 +17,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
modrinth_id=535D1YoA
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.100.7+1.21
|
||||
midnightlib_version=1.5.8-fabric
|
||||
polymer_version=0.9.6+1.21
|
||||
server_translation_version=2.3.1+1.21-pre2
|
||||
fabric_version=0.115.0+1.21.4
|
||||
midnightlib_version=1.6.7-fabric
|
||||
polymer_version=0.11.3+1.21.4
|
||||
server_translation_version=2.4.0+1.21.2-rc1
|
||||
|
||||
@@ -14,29 +14,32 @@ import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class Puddles implements ModInitializer {
|
||||
public static final String MOD_ID = "puddles";
|
||||
public static final Identifier PUDDLE_ID = id("puddle");
|
||||
public static final PuddleBlock Puddle = new PuddleBlock();
|
||||
private final static EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(id("puddle_speed"), 100, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
PuddlesConfig.init(MOD_ID, PuddlesConfig.class);
|
||||
Registry.register(Registries.BLOCK, id("puddle"), Puddle);
|
||||
Registry.register(Registries.ITEM, id("puddle"), new PolymerBlockItem(Puddle, new Item.Settings(), Items.POTION));
|
||||
Registry.register(Registries.BLOCK, PUDDLE_ID, Puddle);
|
||||
Registry.register(Registries.ITEM, PUDDLE_ID, new PolymerBlockItem(Puddle, new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, PUDDLE_ID)), Items.POTION));
|
||||
ServerTickEvents.END_WORLD_TICK.register(world -> world.getPlayers().forEach(player -> {
|
||||
EntityAttributeInstance entityAttributeInstance = player.getAttributes().getCustomInstance(EntityAttributes.GENERIC_WATER_MOVEMENT_EFFICIENCY);
|
||||
EntityAttributeInstance entityAttributeInstance = player.getAttributes().getCustomInstance(EntityAttributes.WATER_MOVEMENT_EFFICIENCY);
|
||||
if (player.getBlockStateAtPos().getBlock() instanceof PuddleBlock) {
|
||||
if (entityAttributeInstance != null) {
|
||||
entityAttributeInstance.removeModifier(entityAttributeModifier);
|
||||
entityAttributeInstance.addTemporaryModifier(entityAttributeModifier);
|
||||
}
|
||||
if (world.random.nextInt(30) == 0) player.playSoundToPlayer(SoundEvents.ENTITY_PLAYER_SWIM, SoundCategory.BLOCKS, 0.5f, 1.2f);
|
||||
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleTypes.SPLASH, false, player.getBlockX() + 0.5f, player.getBlockY() + 0.1f, player.getBlockZ() + 0.5f, 0.5f, 0.1f, 0.5f, 1, 2));
|
||||
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleTypes.SPLASH, false, false, player.getBlockX() + 0.5f, player.getBlockY() + 0.1f, player.getBlockZ() + 0.5f, 0.5f, 0.1f, 0.5f, 1, 2));
|
||||
} else if (player.isInFluid()) {
|
||||
if (entityAttributeInstance != null) entityAttributeInstance.removeModifier(entityAttributeModifier);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,14 @@ import net.minecraft.item.Items;
|
||||
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.potion.Potions;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ItemActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
@@ -38,19 +39,22 @@ import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import net.minecraft.world.tick.ScheduledTickView;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
import static eu.midnightdust.puddles.Puddles.PUDDLE_ID;
|
||||
|
||||
public class PuddleBlock extends Block implements PolymerBlock, BlockWithElementHolder {
|
||||
public PuddleBlock() {
|
||||
super(AbstractBlock.Settings.copy(Blocks.SHORT_GRASS));
|
||||
super(AbstractBlock.Settings.copy(Blocks.SHORT_GRASS).registryKey(RegistryKey.of(RegistryKeys.BLOCK, PUDDLE_ID)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
public ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
ItemStack itemStack = player.getStackInHand(hand);
|
||||
if (itemStack.isEmpty()) {
|
||||
return ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
return ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION;
|
||||
} else {
|
||||
if (itemStack.getItem() == Items.GLASS_BOTTLE) {
|
||||
if (!world.isClient) {
|
||||
@@ -70,9 +74,9 @@ public class PuddleBlock extends Block implements PolymerBlock, BlockWithElement
|
||||
world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
}
|
||||
return ItemActionResult.success(world.isClient);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
else return ItemActionResult.FAIL;
|
||||
else return ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +100,7 @@ public class PuddleBlock extends Block implements PolymerBlock, BlockWithElement
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
public VoxelShape getCullingShape(BlockState state) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@@ -129,12 +133,13 @@ public class PuddleBlock extends Block implements PolymerBlock, BlockWithElement
|
||||
return world.getBlockState(pos.down()).isSideSolidFullSquare(world, pos, Direction.UP);
|
||||
}
|
||||
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) {
|
||||
return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPolymerBlockState(BlockState state) {
|
||||
public BlockState getPolymerBlockState(BlockState state, PacketContext context) {
|
||||
return Blocks.WATER.getDefaultState().with(FluidBlock.LEVEL, 7);
|
||||
}
|
||||
|
||||
@@ -148,7 +153,7 @@ public class PuddleBlock extends Block implements PolymerBlock, BlockWithElement
|
||||
@Override
|
||||
public void attack(ServerPlayerEntity player) {
|
||||
player.playSoundToPlayer(SoundEvents.ENTITY_PLAYER_SPLASH, SoundCategory.BLOCKS, 0.8f, 1.3f);
|
||||
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleTypes.SPLASH, false, pos.getX() + 0.5f, pos.getY() + 0.1f, pos.getZ() + 0.5f, 0.5f, 0.1f, 0.5f, 1, 2));
|
||||
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleTypes.SPLASH, false, false, pos.getX() + 0.5f, pos.getY() + 0.1f, pos.getZ() + 0.5f, 0.5f, 0.1f, 0.5f, 1, 2));
|
||||
}
|
||||
});
|
||||
interactionElement.setSize(1f, 0.06241f);
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.util.profiler.Profilers;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.MutableWorldProperties;
|
||||
import net.minecraft.world.World;
|
||||
@@ -24,8 +25,8 @@ import java.util.function.Supplier;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
public abstract class MixinServerWorld extends World {
|
||||
protected MixinServerWorld(MutableWorldProperties properties, RegistryKey<World> registryRef, DynamicRegistryManager registryManager, RegistryEntry<DimensionType> dimensionEntry, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates) {
|
||||
super(properties, registryRef, registryManager, dimensionEntry, profiler, isClient, debugWorld, biomeAccess, maxChainedNeighborUpdates);
|
||||
protected MixinServerWorld(MutableWorldProperties properties, RegistryKey<World> registryRef, DynamicRegistryManager registryManager, RegistryEntry<DimensionType> dimensionEntry, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) {
|
||||
super(properties, registryRef, registryManager, dimensionEntry, isClient, debugWorld, seed, maxChainedNeighborUpdates);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"),method = "tickChunk")
|
||||
@@ -34,7 +35,7 @@ public abstract class MixinServerWorld extends World {
|
||||
boolean bl = this.isRaining();
|
||||
int x = chunkPos.getStartX();
|
||||
int z = chunkPos.getStartZ();
|
||||
Profiler profiler = this.getProfiler();
|
||||
Profiler profiler = Profilers.get();
|
||||
BlockPos pos;
|
||||
|
||||
if (PuddlesConfig.puddleSpawnRate != 0) {
|
||||
|
||||
Reference in New Issue
Block a user