Skip to content

Commit

Permalink
24e18a
Browse files Browse the repository at this point in the history
  • Loading branch information
gnembon committed May 3, 2024
1 parent 76b8764 commit 0e799bb
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=1.20.6
loader_version=0.15.10
minecraft_version=24w18a
loader_version=0.15.11
jsr305_version=3.0.2
fabric_version=0.97.8+1.20.6

Expand All @@ -17,7 +17,7 @@ org.gradle.jvmargs=-Xmx1G
# The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5)
# This is needed because CF uses too vague names for prereleases and release candidates
# Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN]
release-curse-versions = Minecraft 1.20:1.20.6
release-curse-versions = Minecraft 1.21:1.21-Snapshot
# Whether or not to build another branch on release
release-extra-branch = false
# The name of the second branch to release
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/carpet/helpers/OptimizedExplosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -172,8 +172,8 @@ public static void doExplosionA(Explosion e, ExplosionLogHelper eLogger) {
}
double d11 = d10;

if (entity instanceof LivingEntity) {
d11 = ProtectionEnchantment.getExplosionKnockbackAfterDampener((LivingEntity) entity, d10);
if (entity instanceof LivingEntity lev) {
d11 = d10 * Mth.clamp(1.0 - lev.getAttributeValue(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE), 0.0, 1.0);
}

if (eLogger != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/carpet/mixins/AbstractArrowMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public abstract class AbstractArrowMixin extends Entity
private TrajectoryLogHelper logHelper;
public AbstractArrowMixin(EntityType<?> entityType_1, Level world_1) { super(entityType_1, world_1); }

@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
private void addLogger(final EntityType entityType, final Level level, final ItemStack itemStack, final CallbackInfo ci)
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
private void addLogger(final EntityType entityType, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci)
{
if (LoggerRegistry.__projectiles && !level.isClientSide)
logHelper = new TrajectoryLogHelper("projectiles");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import carpet.CarpetSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -33,7 +34,7 @@ public void playerDestroy(Level world, Player player, BlockPos pos, BlockState s
// drawback - not controlled via loottables, but hey
if (CarpetSettings.movableAmethyst &&
stack.getItem() instanceof PickaxeItem &&
EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0
EnchantmentHelper.getItemEnchantmentLevel(world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(Enchantments.SILK_TOUCH), stack) > 0
)
popResource(world, pos, Items.BUDDING_AMETHYST.getDefaultInstance());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package carpet.mixins;

import carpet.CarpetSettings;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ExperienceOrb;
Expand All @@ -27,15 +28,15 @@ public ExperienceOrb_xpNoCooldownMixin(EntityType<?> type, Level world)
}

@Shadow
protected abstract int repairPlayerItems(Player player, int amount);
protected abstract int repairPlayerItems(ServerPlayer player, int amount);

@Inject(method = "playerTouch", at = @At("HEAD"))
private void addXP(Player player, CallbackInfo ci) {
if (CarpetSettings.xpNoCooldown && !level().isClientSide) {
player.takeXpDelay = 0;
// reducing the count to 1 and leaving vanilla to deal with it
while (this.count > 1) {
int remainder = this.repairPlayerItems(player, this.value);
int remainder = this.repairPlayerItems((ServerPlayer) player, this.value);
if (remainder > 0) {
player.giveExperiencePoints(remainder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import carpet.script.EntityEventsGroup;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.BlockAttachedEntity;
import net.minecraft.world.entity.decoration.HangingEntity;
import net.minecraft.world.level.Level;
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(HangingEntity.class)
@Mixin(BlockAttachedEntity.class)
public abstract class HangingEntity_scarpetEventsMixin extends Entity
{
public HangingEntity_scarpetEventsMixin(EntityType<?> type, Level world)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/carpet/script/api/WorldAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ else if (item instanceof TridentItem || item instanceof SwordItem)
damageAmount = 2;
}
final int finalDamageAmount = damageAmount;
tool.hurtAndBreak(damageAmount, world.getRandom(), null, () -> { if (finalDamageAmount > 0) toolBroke.setTrue(); } );
tool.hurtAndBreak(damageAmount, world, null, () -> { if (finalDamageAmount > 0) toolBroke.setTrue(); } );
if (!isUsingEffectiveTool)
{
dropLoot = false;
Expand All @@ -930,15 +930,15 @@ else if (item instanceof TridentItem || item instanceof SwordItem)

if (dropLoot)
{
if (how < 0 || (tag != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0))
if (how < 0 || (tag != null && EnchantmentHelper.getItemEnchantmentLevel(world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(Enchantments.SILK_TOUCH), tool) > 0))
{
Block.popResource(world, where, new ItemStack(state.getBlock()));
}
else
{
if (how > 0)
{
tool.enchant(Enchantments.FORTUNE, (int) how);
tool.enchant(world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(Enchantments.FORTUNE), (int) how);
}
if (DUMMY_ENTITY == null)
{
Expand Down

0 comments on commit 0e799bb

Please sign in to comment.