Skip to content

Commit

Permalink
1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Oct 4, 2023
1 parent 7d8225d commit 7e8d5d2
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 43 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//file:noinspection GradlePackageVersionRange
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
id 'io.github.juuxel.loom-quiltflower' version '1.7.3'
}

version = "${project.mod_version}+${project.minecraft_base_version}"
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_base_version=1.20
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21
minecraft_base_version=1.20.2
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.2
loader_version=0.14.22

# Mod Properties
mod_version=0.2.10
Expand All @@ -15,19 +15,19 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
# check this on https://fabricmc.net/develop
fabric_version=0.83.0+1.20
fabric_version=0.89.3+1.20.2

# https://github.com/OnyxStudios/Cardinal-Components-API/releases
cca_version=5.2.1
cca_version=5.3.0

# https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/
rei_version=12.0.622
rei_version=13.0.666

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.11.0+1.20
owo_version=0.11.3+1.20.2

# https://www.curseforge.com/minecraft/mc-mods/modmenu/files
modmenu_version=7.0.0
modmenu_version=8.0.0

# https://storage.googleapis.com/devan-maven/
stacc_version=1.5.3-pre.1
stacc_version=1.5.4-pre.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ world, new BlockPos((int) pos.x, (int) pos.y, (int) pos.z), .75
public static final ScreenHandlerType<PiggyBankScreenHandler> PIGGY_BANK_SCREEN_HANDLER_TYPE = new ScreenHandlerType<>(PiggyBankScreenHandler::new, FeatureFlags.DEFAULT_ENABLED_FEATURES);

public static final SoundEvent PIGGY_BANK_BREAK = SoundEvent.of(id("piggy_bank_break"));
public static final LootPoolEntryType MONEY_BAG_ENTRY = new LootPoolEntryType(new MoneyBagLootEntry.Serializer());
public static final LootPoolEntryType MONEY_BAG_ENTRY = new LootPoolEntryType(MoneyBagLootEntry.CODEC);

public static final TagKey<EntityType<?>> THE_BOURGEOISIE = TagKey.of(RegistryKeys.ENTITY_TYPE, id("the_bourgeoisie"));
public static final TagKey<Block> VERY_HEAVY_BLOCKS = TagKey.of(RegistryKeys.BLOCK, id("very_heavy_blocks"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, NumismaticOverhaulBlocks.Entities.SHOP, ShopBlockEntity::tick);
return validateTicker(type, NumismaticOverhaulBlocks.Entities.SHOP, ShopBlockEntity::tick);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected PurseLayerContainer(Sizing horizontalSizing, Sizing verticalSizing) {
}

@Override
protected void drawChildren(OwoUIDrawContext context, int mouseX, int mouseY, float partialTicks, float delta, List<Component> children) {
protected void drawChildren(OwoUIDrawContext context, int mouseX, int mouseY, float partialTicks, float delta, List<? extends Component> children) {
context.getMatrices().push();
context.getMatrices().translate(0, 0, 300);
super.drawChildren(context, mouseX, mouseY, partialTicks, delta, children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ public void drawItems(TextRenderer textRenderer, int x, int y, DrawContext conte
List<ItemStack> originalCoins = data.original()[0] != -1 ? CurrencyConverter.getAsItemStackList(data.original()) : new ArrayList<>();
List<ItemStack> coins = CurrencyConverter.getAsItemStackList(data.value());

context.push().translate(0, 0, 50);

for (int i = 0; i < originalCoins.size(); i++) {
context.drawTexture(new Identifier("textures/gui/container/villager2.png"), x + (originalCoins.get(i).getCount() > 9 ? 14 : 11), y + 3, 0, 176, 9, 2, 512, 256);
context.drawGuiTexture(new Identifier("container/villager/discount_strikethrough"), x + (originalCoins.get(i).getCount() > 9 ? 14 : 11), y + 3, 9, 2);
context.drawItemWithoutEntity(ItemOps.singleCopy(originalCoins.get(i)), x - 4, y - 5 + i * 10);
}

for (int i = 0; i < coins.size(); i++) {
context.drawItemWithoutEntity(ItemOps.singleCopy(coins.get(i)), x - 4, y - 5 + i * 10 + (originalCoins.size() == 0 ? 0 : 10 + originalCoins.size() * 10));
}

context.pop();
}

private static Text createPlaceholder(int count) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.condition.LootCondition;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.entry.LeafEntry;
import net.minecraft.loot.entry.LootPoolEntryType;
import net.minecraft.loot.function.LootFunction;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.dynamic.Codecs;
import net.minecraft.util.math.MathHelper;

import java.util.List;
import java.util.function.Consumer;

public class MoneyBagLootEntry extends LeafEntry {

public static final Codec<MoneyBagLootEntry> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codecs.createStrictOptionalFieldCodec(Codec.INT, "min", 0).forGetter(o -> o.min),
Codec.INT.fieldOf("max").forGetter(o -> o.max)
).and(method_53290(instance)).apply(instance, MoneyBagLootEntry::new));

private final int min;
private final int max;

private MoneyBagLootEntry(int min, int max, int weight, int quality, LootCondition[] conditions, LootFunction[] functions) {
private MoneyBagLootEntry(int min, int max, int weight, int quality, List<LootCondition> conditions, List<LootFunction> functions) {
super(weight, quality, conditions, functions);
this.min = min;
this.max = max;
Expand All @@ -43,21 +52,4 @@ public static LeafEntry.Builder<?> builder(int min, int max) {
public LootPoolEntryType getType() {
return NumismaticOverhaul.MONEY_BAG_ENTRY;
}

public static class Serializer extends LeafEntry.Serializer<MoneyBagLootEntry> {

@Override
public void addEntryFields(JsonObject jsonObject, MoneyBagLootEntry moneyBagLootEntry, JsonSerializationContext jsonSerializationContext) {
super.addEntryFields(jsonObject, moneyBagLootEntry, jsonSerializationContext);
jsonObject.addProperty("min", moneyBagLootEntry.min);
jsonObject.addProperty("max", moneyBagLootEntry.max);
}

@Override
protected MoneyBagLootEntry fromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext, int i, int j, LootCondition[] lootConditions, LootFunction[] lootFunctions) {
final int mix = JsonHelper.getInt(jsonObject, "min", 0);
final int max = JsonHelper.getInt(jsonObject, "max");
return new MoneyBagLootEntry(mix, max, i, j, lootConditions, lootFunctions);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.glisco.numismaticoverhaul.villagers.data.NumismaticVillagerTradesRegistry;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.fabricmc.fabric.impl.object.builder.TradeOfferInternals;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerProfession;
Expand All @@ -21,9 +22,9 @@ public class TradeOfferInternalsMixin {
* @author glisco
*/
@Overwrite(remap = false)
public static synchronized void registerVillagerOffers(VillagerProfession profession, int level, Consumer<List<TradeOffers.Factory>> factory) {
public static synchronized void registerVillagerOffers(VillagerProfession profession, int level, TradeOfferHelper.VillagerOffersAdder factory) {
final var factories = new ArrayList<TradeOffers.Factory>();
factory.accept(factories);
factory.onRegister(factories, false);

NumismaticVillagerTradesRegistry.registerFabricVillagerTrades(profession, level, factories);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Mixin(TradeOfferList.class)
public class TradeOfferListMixin {

@Inject(method = "method_43715", at = @At(value = "INVOKE", ordinal = 4, target = "Lnet/minecraft/network/PacketByteBuf;writeInt(I)Lio/netty/buffer/ByteBuf;", shift = At.Shift.AFTER))
@Inject(method = "method_43715", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeInt(I)Lnet/minecraft/network/PacketByteBuf;", ordinal = 4, shift = At.Shift.AFTER))
private static void writeReputation(PacketByteBuf buf, TradeOffer offer, CallbackInfo ci) {
buf.writeVarInt(((NumismaticTradeOfferExtensions) offer).numismatic$getReputation());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void registerFabricWanderingTraderTrades(int level, List<TradeOffe
getOrDefaultAndAdd(REMAPPED_FABRIC_WANDERING_TRADER_TRADES, level, new ArrayList<>()).addAll(factories.stream().map(RemappingTradeWrapper::wrap).toList());
}

// -- NO datapack trades - this registry is cleared on reload--
// -- NO datapack trades - this registry is cleared on reload --

public static void registerVillagerTrade(VillagerProfession profession, int level, TradeOffers.Factory trade) {
getVillagerTradeList(TRADES_REGISTRY, profession, level).add(trade);
Expand All @@ -55,7 +55,7 @@ public static void wrapModVillagers() {
}

private static List<TradeOffers.Factory> getVillagerTradeList(HashMap<VillagerProfession, Int2ObjectOpenHashMap<List<TradeOffers.Factory>>> registry, VillagerProfession profession, int level) {
Int2ObjectOpenHashMap<List<TradeOffers.Factory>> villagerMap = getOrDefaultAndAdd(registry, profession, new Int2ObjectOpenHashMap<>());
var villagerMap = getOrDefaultAndAdd(registry, profession, new Int2ObjectOpenHashMap<>());
return getOrDefaultAndAdd(villagerMap, level, new ArrayList<>());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.glisco.numismaticoverhaul.villagers.exceptions.DeserializationException;
import com.glisco.numismaticoverhaul.villagers.json.TradeJsonAdapter;
import com.google.gson.JsonObject;
import net.minecraft.block.SuspiciousStewIngredient;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.item.ItemStack;
Expand All @@ -19,6 +20,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;


public class SellSusStewAdapter extends TradeJsonAdapter {

Expand Down Expand Up @@ -57,7 +60,7 @@ public Factory(StatusEffect effect, int price, int duration, int experience, flo
@Override
public TradeOffer create(Entity entity, Random random) {
ItemStack susStew = new ItemStack(Items.SUSPICIOUS_STEW, 1);
SuspiciousStewItem.addEffectToStew(susStew, this.effect, this.duration);
SuspiciousStewItem.addEffectsToStew(susStew, List.of(new SuspiciousStewIngredient.StewEffect(this.effect, this.duration)));

return new TradeOffer(CurrencyHelper.getClosest(price), susStew, this.maxUses, this.experience, this.multiplier);
}
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 @@ -30,10 +30,10 @@
"depends": {
"fabricloader": ">=0.10.8",
"fabric": "*",
"minecraft": ">=1.19.3",
"minecraft": ">=1.20.2",
"cardinal-components-base": "*",
"cardinal-components-entity": "*",
"owo": ">=0.9.2"
"owo": ">=0.11.3"
},
"custom": {
"cardinal-components": [
Expand Down

0 comments on commit 7e8d5d2

Please sign in to comment.