Skip to content

Commit

Permalink
Update to 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
GameduJS committed May 8, 2024
1 parent bb4c10e commit 77c93b5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ processResources {
}
}

def targetJavaVersion = 17
def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.11
# Mod Properties
mod_version=1.2-1.20.4
maven_group=de.gamedude
archives_base_name=EasyVillagerTrade
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.97.0+1.20.4
fabric_version=0.98.0+1.20.6
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.argument.ArgumentTypes;
import net.minecraft.command.argument.RegistryEntryArgumentType;
import net.minecraft.command.argument.RegistryEntryReferenceArgumentType;
import net.minecraft.command.argument.serialize.ArgumentSerializer;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
Expand All @@ -36,10 +39,10 @@ public void register(CommandDispatcher<FabricClientCommandSource> dispatcher, Co
dispatcher.register(literal(command_base)
.then(literal("select").then(literal("close").executes(this::executeSelectionClosest)).executes(this::executeSelection))
.then(literal("search")
.then(literal("add").then(argument("maxPrice", IntegerArgumentType.integer()).then(argument("enchantment", RegistryEntryArgumentType.registryEntry(registryAccess, RegistryKeys.ENCHANTMENT))
.then(literal("add").then(argument("maxPrice", IntegerArgumentType.integer()).then(argument("enchantment", RegistryEntryReferenceArgumentType.registryEntry(registryAccess, RegistryKeys.ENCHANTMENT))
.executes(this::executeAddTradeRequest).then(argument("level", IntegerArgumentType.integer()).executes(this::executeAddTradeRequest)))))

.then(literal("remove").then(argument("enchantment", RegistryEntryArgumentType.registryEntry(registryAccess, RegistryKeys.ENCHANTMENT))
.then(literal("remove").then(argument("enchantment", RegistryEntryReferenceArgumentType.registryEntry(registryAccess, RegistryKeys.ENCHANTMENT))
.executes(this::executeRemoveTradeRequest)))

.then(literal("list").executes(this::executeListTradeRequest)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,25 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.LocalRandom;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOfferList;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.World;

import java.util.Map;

public class EasyVillagerTradeBase {
private TradingState state;

Expand Down Expand Up @@ -77,7 +75,7 @@ public void handle() {
case APPLY_TRADE -> tradeInterface.applyTrade();
case PICKUP_TRADE -> tradeInterface.pickupBook();
case WAIT_JOB_LOSS -> {
if(selectionInterface.getVillager().getVillagerData().getProfession() == VillagerProfession.NONE)
if (selectionInterface.getVillager().getVillagerData().getProfession() == VillagerProfession.NONE)
setState(TradingState.PLACE_WORKSTATION);
}
}
Expand All @@ -87,7 +85,7 @@ private void handlePlacement() {
ClientPlayerEntity player = minecraftClient.player;
BlockPos lecternPos = selectionInterface.getLecternPos();

if(player.getOffHandStack().equals(ItemStack.EMPTY)) {
if (player.getOffHandStack().equals(ItemStack.EMPTY)) {
player.sendMessage(Text.translatable("evt.logic.lectern_non"));
setState(TradingState.INACTIVE);
return;
Expand All @@ -109,13 +107,13 @@ private void handleBreak() {
if (world == null || player == null)
return;
ItemStack axe = player.getMainHandStack();
if(axe.getMaxDamage() - axe.getDamage() < 20) {
if (axe.getMaxDamage() - axe.getDamage() < 20) {
player.sendMessage(Text.translatable("evt.logic.axe_durability"));
setState(TradingState.INACTIVE);
return;
}

if(blockPos == null) {
if (blockPos == null) {
player.sendMessage(Text.translatable("evt.logic.pos_not_set"));
setState(TradingState.INACTIVE);
return;
Expand All @@ -137,19 +135,22 @@ public void checkVillagerOffers(TradeOfferList tradeOffers) {
bookOffer = offers;
break;
}

if (bookOffer == null) {
setState(TradingState.BREAK_WORKSTATION);
return;
}
Map<Enchantment, Integer> enchantmentMap = EnchantmentHelper.get(bookOffer.getSellItem());
Enchantment bookEnchantment = enchantmentMap.keySet().iterator().next();
int level = enchantmentMap.values().iterator().next();

TradeRequest offer = new TradeRequest(bookEnchantment, level, bookOffer.getAdjustedFirstBuyItem().getCount());

ItemEnchantmentsComponent enchantments = EnchantmentHelper.getEnchantments(bookOffer.getSellItem());
Enchantment bookEnchantment = enchantments.getEnchantments().iterator().next().value();
int level = enchantments.getLevel(bookEnchantment);

TradeRequest offer = new TradeRequest(bookEnchantment, level, bookOffer.getDisplayedFirstBuyItem().getCount());

if (tradeRequestContainer.matchesAny(offer)) {
minecraftClient.player.sendMessage(Text.translatable("evt.logic.trade_found", "§e" + bookEnchantment.getName(level).getString(), "§a" + offer.maxPrice()));
minecraftClient.getSoundManager().play(new PositionedSoundInstance(SoundEvents.BLOCK_AMETHYST_CLUSTER_BREAK, SoundCategory.MASTER, 2f, 1f, new LocalRandom(0), MinecraftClient.getInstance().player.getBlockPos()));
minecraftClient.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.BLOCK_AMETHYST_CLUSTER_BREAK, 1f));

tradeRequestContainer.removeTradeRequestByEnchantment(bookEnchantment);
tradeInterface.setTradeSlotID(tradeOffers.indexOf(bookOffer));
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"EasyVillagerTrade.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.21",
"fabricloader": ">=0.15.11",
"fabric-api": "*",
"minecraft": ">=1.20.2"
"minecraft": ">=1.20.5"
}
}

0 comments on commit 77c93b5

Please sign in to comment.