Skip to content

Commit

Permalink
Updated to 1.20-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Quplet committed Jun 3, 2023
1 parent 84ef2aa commit 950737e
Show file tree
Hide file tree
Showing 26 changed files with 181 additions and 130 deletions.
6 changes: 2 additions & 4 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
1.3.4-1.19.4
1.3.5-1.20

Fixes/Changes:
- Removed old debug logging
- Adjusted the chance and range of Lucky Miner's effect
- Cloth Config is now bundled into the mod
- Updated to Minecraft 1.20
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.17
minecraft_version=1.20-rc1
yarn_mappings=1.20-rc1+build.2
loader_version=0.14.21

# Mod Properties
mod_version = 1.3.4-1.19.4
mod_version = 1.3.5-1.20-rc.1
maven_group = qu
archives_base_name = qu-enchantments

# Dependencies
fabric_version=0.75.3+1.19.4
fabric_version=0.83.0+1.20
fabric_asm_version = v2.3
mixin_extras_version = 0.1.1
mod_menu_version = 6.2.1
cloth_config_version = 10.0.96
mod_menu_version = 7.0.0-beta.2
cloth_config_version = 11.0.98
11 changes: 5 additions & 6 deletions src/main/java/qu/quEnchantments/blocks/HotObsidianBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
Expand Down Expand Up @@ -37,11 +36,11 @@ public HotObsidianBlock(Settings settings) {
@Override
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) {
super.afterBreak(world, player, pos, state, blockEntity, stack);
if (EnchantmentHelper.getEquipmentLevel(Enchantments.SILK_TOUCH, player) == 0) {
Material material = world.getBlockState(pos.down()).getMaterial();
if (material.blocksMovement() || material.isLiquid()) {
world.setBlockState(pos, Blocks.LAVA.getDefaultState());
}
if (EnchantmentHelper.getEquipmentLevel(Enchantments.SILK_TOUCH, player) != 0) return;

BlockState blockStateDown = world.getBlockState(pos.down());
if (blockStateDown.blocksMovement() || blockStateDown.isLiquid()) {
world.setBlockState(pos, Blocks.LAVA.getDefaultState());
}
}

Expand Down
22 changes: 20 additions & 2 deletions src/main/java/qu/quEnchantments/blocks/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package qu.quEnchantments.blocks;

import net.minecraft.block.*;
import net.minecraft.block.enums.Instrument;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
Expand All @@ -11,8 +13,24 @@

public class ModBlocks {

public static final Block HOT_OBSIDIAN = register("hot_obsidian", new HotObsidianBlock(AbstractBlock.Settings.of(Material.STONE, MapColor.BLACK).requiresTool().strength(35.0f, 800.0f).luminance(state -> 7)));
public static final Block CLOUD = register("cloud", new CloudBlock(AbstractBlock.Settings.of(Material.POWDER_SNOW).sounds(BlockSoundGroup.SNOW).breakInstantly().nonOpaque().suffocates(ModBlocks::never)));
public static final Block HOT_OBSIDIAN = register(
"hot_obsidian",
new HotObsidianBlock(AbstractBlock.Settings.copy(Blocks.OBSIDIAN).luminance(state -> 7))
);

//public static final Block CLOUD = register("cloud", new CloudBlock(AbstractBlock.Settings.of(Material.POWDER_SNOW).sounds(BlockSoundGroup.SNOW).breakInstantly().nonOpaque().suffocates(ModBlocks::never)));
public static final Block CLOUD = register(
"cloud",
new CloudBlock(
AbstractBlock.Settings.create()
.mapColor(MapColor.CLEAR)
.sounds(BlockSoundGroup.SNOW)
.breakInstantly()
.nonOpaque()
.suffocates(ModBlocks::never)
.pistonBehavior(PistonBehavior.DESTROY)
)
);

private static Block register(String name, Block block) {
return Registry.register(Registries.BLOCK, new Identifier(QuEnchantments.MOD_ID, name), block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import qu.quEnchantments.QuEnchantments;
import qu.quEnchantments.enchantments.QuEnchantment;
import qu.quEnchantments.util.config.ModConfig;
Expand Down Expand Up @@ -63,8 +64,16 @@ public boolean isAvailableForEnchantingTable() {

@Override
public void tickWhileEquipped(LivingEntity livingEntity, ItemStack stack, int level) {
if (livingEntity.world.isClient || (livingEntity instanceof PlayerEntity player && player.getAbilities().creativeMode) || livingEntity.age % 20 != 10) return;
List<Entity> mobs = livingEntity.world.getOtherEntities(livingEntity, livingEntity.getBoundingBox().expand(CONFIG.radius), entity -> entity.isAlive() && !entity.isTeammate(livingEntity) && entity instanceof MobEntity mob && mob.getTarget() == null);
World world;
if ((world = livingEntity.getWorld()).isClient ||
(livingEntity instanceof PlayerEntity player && player.getAbilities().creativeMode) ||
livingEntity.age % 20 != 10) return;

List<Entity> mobs = world.getOtherEntities(
livingEntity,
livingEntity.getBoundingBox().expand(CONFIG.radius),
entity -> entity.isAlive() && !entity.isTeammate(livingEntity) && entity instanceof MobEntity mob && mob.getTarget() == null);

for (Entity mob : mobs) {
((MobEntity)mob).setTarget(livingEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean isAcceptableItem(ItemStack stack) {

@Override
public void onUserDamaged(LivingEntity user, Entity attacker, int level) {
if (user.world.isClient || attacker == null) return;
if (user.getWorld().isClient || attacker == null) return;
if (attacker instanceof PlayerEntity player && player.getAbilities().creativeMode) return;
if (attacker instanceof LivingEntity livingEntity) {
for (int i = 0; i < 7; i++) {
Expand All @@ -82,7 +82,7 @@ public void onUserDamaged(LivingEntity user, Entity attacker, int level) {

@Override
public void tickWhileEquipped(LivingEntity entity, ItemStack stack, int level) {
World world = entity.world;
World world = entity.getWorld();
if (!world.isClient) {
if (entity.isWet() && entity.getRandom().nextFloat() < 0.05f && !(entity instanceof PlayerEntity player && player.getAbilities().creativeMode)) {
entity.removeAllPassengers();
Expand All @@ -109,24 +109,24 @@ private static double clampEither(double min, double max, double value) {
// Functionally equivalent to the Enderman's teleport
public static boolean teleportTo(LivingEntity subject, double x, double y, double z) {
BlockPos.Mutable mutable = new BlockPos.Mutable(x, y, z);
while (mutable.getY() > subject.world.getBottomY() && !subject.world.getBlockState(mutable).getMaterial().blocksMovement()) {
while (mutable.getY() > subject.getWorld().getBottomY() && !subject.getWorld().getBlockState(mutable).blocksMovement()) {
mutable.move(Direction.DOWN);
}
BlockState blockState = subject.world.getBlockState(mutable);
boolean bl = blockState.getMaterial().blocksMovement();
BlockState blockState = subject.getWorld().getBlockState(mutable);
boolean bl = blockState.blocksMovement();
boolean bl2 = blockState.getFluidState().isIn(FluidTags.WATER);
if (!bl || bl2) {
return false;
}
Vec3d vec3d = subject.getPos();
boolean bl3 = subject.teleport(x, y, z, true);
if (bl3) {
subject.world.emitGameEvent(GameEvent.TELEPORT, vec3d, GameEvent.Emitter.of(subject));
subject.getWorld().emitGameEvent(GameEvent.TELEPORT, vec3d, GameEvent.Emitter.of(subject));
if (!subject.isSilent()) {
if (subject instanceof PlayerEntity) {
subject.world.playSound((PlayerEntity) subject, subject.prevX, subject.prevY, subject.prevZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, subject.getSoundCategory(), 1.0f, 1.0f);
subject.getWorld().playSound((PlayerEntity) subject, subject.prevX, subject.prevY, subject.prevZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, subject.getSoundCategory(), 1.0f, 1.0f);
} else {
subject.world.playSound(null, subject.prevX, subject.prevY, subject.prevZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, subject.getSoundCategory(), 1.0f, 1.0f);
subject.getWorld().playSound(null, subject.prevX, subject.prevY, subject.prevZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, subject.getSoundCategory(), 1.0f, 1.0f);
}
subject.playSound(SoundEvents.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package qu.quEnchantments.enchantments.armor;

import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidBlock;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.DepthStriderEnchantment;
import net.minecraft.enchantment.Enchantment;
Expand All @@ -13,6 +13,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import qu.quEnchantments.QuEnchantments;
import qu.quEnchantments.blocks.ModBlocks;
import qu.quEnchantments.enchantments.QuEnchantment;
Expand Down Expand Up @@ -71,23 +72,25 @@ public boolean canAccept(Enchantment other) {

@Override
public void tickEquippedWhileMoving(LivingEntity entity, BlockPos pos, ItemStack stack, int level) {
if (entity.world.isClient || !entity.isOnGround()) return;
World world = entity.getWorld();
if (world.isClient || !entity.isOnGround()) return;
BlockState blockState = ModBlocks.HOT_OBSIDIAN.getDefaultState();
int f = Math.min(16, CONFIG.radius + level - 1);
BlockPos.Mutable mutable = new BlockPos.Mutable();
for (BlockPos blockPos2 : BlockPos.iterate(pos.add(-f, -1, -f), pos.add(f, -1, f))) {
if (!blockPos2.isWithinDistance(entity.getPos(), f)) continue;

mutable.set(blockPos2.getX(), blockPos2.getY() + 1, blockPos2.getZ());
BlockState blockState2 = entity.world.getBlockState(mutable);
BlockState blockState2 = world.getBlockState(mutable);
BlockState blockState3;
if (!blockState2.isAir() || (blockState3 = entity.world.getBlockState(blockPos2)).getMaterial() != Material.LAVA ||
blockState3.get(FluidBlock.LEVEL) != 0 || !blockState.canPlaceAt(entity.world, blockPos2) ||
!entity.world.canPlace(blockState, blockPos2, ShapeContext.absent())) continue;
// TODO: test that this still works properly
if (!blockState2.isAir() || !(blockState3 = world.getBlockState(blockPos2)).isOf(Blocks.LAVA) ||
blockState3.get(FluidBlock.LEVEL) != 0 || !blockState.canPlaceAt(world, blockPos2) ||
!world.canPlace(blockState, blockPos2, ShapeContext.absent())) continue;

entity.world.setBlockState(blockPos2, blockState);
entity.world.scheduleBlockTick(blockPos2, ModBlocks.HOT_OBSIDIAN, MathHelper.nextInt(entity.getRandom(), 60, 120));
entity.world.syncWorldEvent(ModWorldEvents.HOT_OBSIDIAN_CREATION, blockPos2, 0);
world.setBlockState(blockPos2, blockState);
world.scheduleBlockTick(blockPos2, ModBlocks.HOT_OBSIDIAN, MathHelper.nextInt(entity.getRandom(), 60, 120));
world.syncWorldEvent(ModWorldEvents.HOT_OBSIDIAN_CREATION, blockPos2, 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import qu.quEnchantments.QuEnchantments;
import qu.quEnchantments.blocks.ModBlocks;
import qu.quEnchantments.enchantments.CorruptedEnchantment;
Expand Down Expand Up @@ -62,27 +63,32 @@ public boolean canAccept(Enchantment other) {

@Override
public void tickEquippedWhileMoving(LivingEntity entity, BlockPos pos, ItemStack stack, int level) {
if (entity.world.isClient || !entity.isOnGround() || !entity.isSneaking()) return;
World world;
final double sinkDistance = 0.875;
if ((world = entity.getWorld()).isClient || !entity.isOnGround() || !entity.isSneaking()) return;
BlockState blockState = ModBlocks.CLOUD.getDefaultState();
int f = Math.min(16, CONFIG.radius);
BlockPos.Mutable mutable = new BlockPos.Mutable();
for (BlockPos blockPos2 : BlockPos.iterate(new BlockPos(entity.getBlockX() - f, (int)(entity.getY() - 0.875), entity.getBlockZ() - f),
new BlockPos(entity.getBlockX() + f, (int)(entity.getY() - 0.875), entity.getBlockZ() + f))) {
// The reason for -0.875 is that 0.125 is how much something will sink into a cloud block before the collision box
if (!entity.world.getBlockState(blockPos2).equals(Blocks.AIR.getDefaultState()) ||
for (BlockPos blockPos2 : BlockPos.iterate(new BlockPos(entity.getBlockX() - f, (int)(entity.getY() - sinkDistance), entity.getBlockZ() - f),
new BlockPos(entity.getBlockX() + f, (int)(entity.getY() - sinkDistance), entity.getBlockZ() + f))) {

if (!world.getBlockState(blockPos2).equals(Blocks.AIR.getDefaultState()) ||
!blockPos2.isWithinDistance(entity.getPos(), Math.max(f, 1))) continue;

mutable.set(blockPos2.getX(), blockPos2.getY() + 1, blockPos2.getZ());
BlockState blockState2 = entity.world.getBlockState(mutable);
if (!blockState2.isAir() || !blockState.canPlaceAt(entity.world, blockPos2) ||
!entity.world.canPlace(blockState, blockPos2, ShapeContext.absent())) continue;
BlockState blockState2 = world.getBlockState(mutable);
if (!blockState2.isAir() || !blockState.canPlaceAt(world, blockPos2) ||
!world.canPlace(blockState, blockPos2, ShapeContext.absent())) continue;

entity.world.setBlockState(blockPos2, blockState);
int bl = entity.world.getDimension().ultrawarm() ? 1 : 2;
world.setBlockState(blockPos2, blockState);
int bl = world.getDimension().ultrawarm() ? 1 : 2;
int duration = Math.max(1, CONFIG.cloudDuration) * bl * level;
entity.world.scheduleBlockTick(blockPos2, ModBlocks.CLOUD, MathHelper.nextInt(entity.getRandom(),
duration, duration * 2));
entity.world.syncWorldEvent(ModWorldEvents.CLOUD_BLOCK_CREATION, blockPos2, 0);
world.scheduleBlockTick(
blockPos2,
ModBlocks.CLOUD,
MathHelper.nextInt(entity.getRandom(), duration, duration * 2)
);
world.syncWorldEvent(ModWorldEvents.CLOUD_BLOCK_CREATION, blockPos2, 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean isAvailableForEnchantingTable() {
@Override
public void tickWhileEquipped(LivingEntity wearer, ItemStack stack, int level) {
if (!(wearer instanceof PlayerEntity player && player.getAbilities().creativeMode) && wearer.age % 20 == 0) stack.setDamage(Math.min(stack.getMaxDamage(), stack.getDamage() + 1));
if (wearer.world.isClient) return;
if (wearer.getWorld().isClient) return;
EntityAttributeInstance instance = wearer.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_SPEED);
if (instance == null) return;
if (stack.getDamage() < stack.getMaxDamage() && ((IEntity)wearer).getInaneTicks() <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public boolean isAvailableForEnchantingTable() {
@Override
public void tickWhileEquipped(LivingEntity wearer, ItemStack stack, int level) {
if (!(wearer instanceof PlayerEntity player && player.getAbilities().creativeMode) && wearer.age % 20 == 0) stack.setDamage(Math.min(stack.getMaxDamage(), stack.getDamage() + 1));
if (wearer instanceof PlayerEntity player && player.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION) && player.canFoodHeal() && stack.getDamage() < stack.getMaxDamage() && ((IEntity)player).getInaneTicks() <= 0) {
if (wearer instanceof PlayerEntity player && player.getWorld().getGameRules().getBoolean(GameRules.NATURAL_REGENERATION) && player.canFoodHeal() && stack.getDamage() < stack.getMaxDamage() && ((IEntity)player).getInaneTicks() <= 0) {
int foodTickTimer = ((HungerManagerAccessor) player.getHungerManager()).getFoodTickTimer();
if (foodTickTimer == 5 && player.getHungerManager().getSaturationLevel() > 0.0f && player.getHungerManager().getFoodLevel() >= 20) {
float f = Math.min(player.getHungerManager().getSaturationLevel(), 6.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean isAvailableForEnchantingTable() {
@Override
public void tickWhileEquipped(LivingEntity wearer, ItemStack stack, int level) {
if (!(wearer instanceof PlayerEntity player && player.getAbilities().creativeMode) && wearer.age % 20 == 0) stack.setDamage(Math.min(stack.getMaxDamage(), stack.getDamage() + 1));
if (wearer.world.isClient) return;
if (wearer.getWorld().isClient) return;
EntityAttributeInstance instance = wearer.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
if (instance == null) return;
if (stack.getDamage() < stack.getMaxDamage() && ((IEntity)wearer).getInaneTicks() <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import qu.quEnchantments.QuEnchantments;
import qu.quEnchantments.enchantments.ModEnchantments;
import qu.quEnchantments.enchantments.QuEnchantment;
Expand Down Expand Up @@ -54,7 +55,8 @@ public boolean isAvailableForEnchantingTable() {

@Override
public void onBlock(LivingEntity defender, LivingEntity attacker, ItemStack stack, int level) {
if (defender.world.isClient) return;
World world;
if ((world = defender.getWorld()).isClient) return;
double dx = defender.getX() - attacker.getX();
double dz = defender.getZ() - attacker.getZ();
while (dx * dx + dz * dz < 1.0E-4) {
Expand All @@ -67,13 +69,13 @@ public void onBlock(LivingEntity defender, LivingEntity attacker, ItemStack stac
ItemStack shield = defender.getActiveItem();
shield.setDamage(shield.getMaxDamage() - 1);
shield.damage(50, defender, e -> e.sendToolBreakStatus(defender.getActiveHand()));
defender.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8f, 0.8f + defender.world.random.nextFloat() * 0.4f);
Random random = defender.world.getRandom();
defender.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8f, 0.8f + world.random.nextFloat() * 0.4f);
Random random = world.getRandom();
for (int i = 0; i < 10; ++i) {
double d = random.nextGaussian() * 0.02;
double e = random.nextGaussian() * 0.02;
double f = random.nextGaussian() * 0.02;
((ServerWorld) defender.world).spawnParticles(ParticleTypes.LARGE_SMOKE, defender.getParticleX(1.0), defender.getRandomBodyY(), defender.getParticleZ(1.0), 1, d, e, f, 0.0);
((ServerWorld) world).spawnParticles(ParticleTypes.LARGE_SMOKE, defender.getParticleX(1.0), defender.getRandomBodyY(), defender.getParticleZ(1.0), 1, d, e, f, 0.0);
}
}
}
Expand Down
Loading

0 comments on commit 950737e

Please sign in to comment.