Skip to content

Commit

Permalink
6.0.0 update (1.20.1 port)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dqu1J committed Aug 1, 2023
1 parent 5ecbd34 commit 4a1d36f
Show file tree
Hide file tree
Showing 54 changed files with 356 additions and 228 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'io.github.juuxel.loom-quiltflower' version '1.7.1'
id 'maven-publish'
}
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.4
minecraft_version=1.20.1
loader_version=0.14.4
# Mod Properties
mod_version=5.3.0
mod_version=6.0.0
maven_group=AdditionalAdditions
archives_base_name=AdditionalAdditions
# Dependencies
fabric_version=0.75.3+1.19.4
modmenu_version=5.0.2
libgui_version=6.5.2+1.19.3
lambdynamiclights_version=2.2.0+1.19.3
fabric_version=0.85.0+1.20.1
modmenu_version=7.1.0
libgui_version=8.0.1+1.20
lambdynamiclights_version=2.3.1+1.20.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.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import dev.lambdaurora.lambdynlights.api.DynamicLightHandlers;
import dqu.additionaladditions.behaviour.BehaviourManager;
import dqu.additionaladditions.config.Config;
import dqu.additionaladditions.misc.LootHandler;
import dqu.additionaladditions.registry.*;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.packs.PackType;
Expand Down Expand Up @@ -32,6 +34,12 @@ public void onInitialize() {
AdditionalPotions.registerAll();
AdditionalMusicDiscs.registerAll();

LootTableEvents.MODIFY.register(((resourceManager, lootManager, id, table, setter) -> {
LootHandler.handle(id, table);
}));

LootHandler.postInit();

if (FabricLoader.getInstance().isModLoaded("lambdynlights")) {
DynamicLightHandlers.registerDynamicLightHandler(AdditionalEntities.GLOW_STICK_ENTITY_ENTITY_TYPE, entity -> 12);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onInitializeClient() {

FabricModelPredicateProviderRegistry.register(AdditionalItems.DEPTH_METER_ITEM, new ResourceLocation("angle"), (itemStack, clientWorld, livingEntity, worldSeed) -> {
if (livingEntity == null) return 0.3125F;
Level world = livingEntity.level;
Level world = livingEntity.level();
if (world == null) return 0.3125F;

float sea = world.getSeaLevel();
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/dqu/additionaladditions/block/RopeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import dqu.additionaladditions.config.Config;
import dqu.additionaladditions.config.ConfigValues;
import dqu.additionaladditions.registry.AdditionalBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -165,14 +164,14 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
return InteractionResult.PASS;
}

if (!player.getMainHandItem().is(Item.byBlock(AdditionalBlocks.ROPE_BLOCK))) {
if (!player.getMainHandItem().is(Item.byBlock(this))) {
return InteractionResult.PASS;
}

BlockPos down = pos.relative(Direction.DOWN);
BlockState statedown = world.getBlockState(down);

if (statedown.is(AdditionalBlocks.ROPE_BLOCK)) {
if (statedown.is(this)) {
return statedown.getBlock().use(statedown, world, down, player, hand, hit);
} else if (statedown.isAir() && !world.isOutsideBuildHeight(down.getY())) {
world.setBlockAndUpdate(down, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public enum ConfigValues {
POCKET_JUKEBOX(6, new ConfigProperty("PocketJukebox")),
CHICKEN_NUGGET(6, new ConfigProperty("ChickenNugget")),
POWERED_RAILS_COPPER_RECIPE(6, new ConfigProperty("PoweredRailsCopperRecipe")),
GOLD_RING(6, new ConfigProperty("GoldRing")),
GLOW_BERRY_GLOW(6, new ConfigProperty("GlowBerryEatGlow", new ListConfigValue()
.put(new ConfigProperty("enabled"))
.put(new ConfigProperty("duration", new IntegerConfigValue(5)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ protected Item getDefaultItem() {

protected void onHit(HitResult hitResult) {
super.onHit(hitResult);
if (!this.level.isClientSide()) {
if (!this.level().isClientSide()) {
this.remove(RemovalReason.DISCARDED);
BlockPos pos = BlockPos.containing(this.getX(), this.getY(), this.getZ());
if (this.level.getBlockState(pos).isAir()) {
this.level.setBlockAndUpdate(pos, AdditionalBlocks.GLOW_STICK_BLOCK.defaultBlockState()
.setValue(GlowStickBlock.FLIPPED, level.getRandom().nextBoolean()));
this.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.GLASS_PLACE, SoundSource.BLOCKS, 1.0f, 1.0f);
if (this.level().getBlockState(pos).isAir()) {
this.level().setBlockAndUpdate(pos, AdditionalBlocks.GLOW_STICK_BLOCK.defaultBlockState()
.setValue(GlowStickBlock.FLIPPED, level().getRandom().nextBoolean()));
this.level().playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.GLASS_PLACE, SoundSource.BLOCKS, 1.0f, 1.0f);
} else {
ItemStack stack = new ItemStack(AdditionalItems.GLOW_STICK_ITEM, 1);
ItemEntity entity = new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), stack);
this.level.addFreshEntity(entity);
ItemEntity entity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), stack);
this.level().addFreshEntity(entity);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package dqu.additionaladditions.item;

import dqu.additionaladditions.AdditionalAdditions;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.SmithingTemplateItem;

import java.util.List;

public class AdditionalSmithingTemplate extends SmithingTemplateItem {
private static final ChatFormatting TITLE_FORMAT = ChatFormatting.GRAY;
private static final ChatFormatting DESCRIPTION_FORMAT = ChatFormatting.BLUE;

private AdditionalSmithingTemplate(Component appliesTo, Component ingredients, Component upgradeDescription, Component baseSlotDescription, Component additionsSlotDescription, List<ResourceLocation> baseSlotEmptyIcons, List<ResourceLocation> additionalSlotEmptyIcons) {
super(appliesTo, ingredients, upgradeDescription, baseSlotDescription, additionsSlotDescription, baseSlotEmptyIcons, additionalSlotEmptyIcons);
}

public static SmithingTemplateItem create(String id, List<ResourceLocation> baseSlotEmptyIcons, List<ResourceLocation> additionalSlotEmptyIcons) {
var appliesTo = Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(AdditionalAdditions.namespace, "smithing_template."+id+".applies_to"))).withStyle(DESCRIPTION_FORMAT);
var upgradeDescription = Component.translatable(Util.makeDescriptionId("upgrade", new ResourceLocation(AdditionalAdditions.namespace, id))).withStyle(TITLE_FORMAT);
var ingredients = Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(AdditionalAdditions.namespace, "smithing_template."+id+".ingredients"))).withStyle(DESCRIPTION_FORMAT);
var baseSlotDescription = Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(AdditionalAdditions.namespace, "smithing_template."+id+".base_slot_description")));
var additionsSlotDescription = Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(AdditionalAdditions.namespace, "smithing_template."+id+".additions_slot_description")));

return new AdditionalSmithingTemplate(
appliesTo,
ingredients,
upgradeDescription,
baseSlotDescription,
additionsSlotDescription,
baseSlotEmptyIcons,
additionalSlotEmptyIcons
);
}

public static List<ResourceLocation> iconsEquipment() {
return List.of(
SmithingIcon.HELMET.location(),
SmithingIcon.CHESTPLATE.location(),
SmithingIcon.LEGGINGS.location(),
SmithingIcon.BOOTS.location(),
SmithingIcon.HOE.location(),
SmithingIcon.AXE.location(),
SmithingIcon.PICKAXE.location(),
SmithingIcon.SWORD.location(),
SmithingIcon.SHOVEL.location()
);
}

public enum SmithingIcon {
HELMET(new ResourceLocation("item/empty_armor_slot_helmet")),
CHESTPLATE(new ResourceLocation("item/empty_armor_slot_chestplate")),
LEGGINGS(new ResourceLocation("item/empty_armor_slot_leggings")),
BOOTS(new ResourceLocation("item/empty_armor_slot_boots")),
HOE(new ResourceLocation("item/empty_slot_hoe")),
AXE(new ResourceLocation("item/empty_slot_axe")),
SWORD(new ResourceLocation("item/empty_slot_sword")),
SHOVEL(new ResourceLocation("item/empty_slot_shovel")),
PICKAXE(new ResourceLocation("item/empty_slot_pickaxe")),
INGOT(new ResourceLocation("item/empty_slot_ingot")),
REDSTONE_DUST(new ResourceLocation("item/empty_slot_redstone_dust")),
QUARTZ(new ResourceLocation("item/empty_slot_quartz")),
EMERALD(new ResourceLocation("item/empty_slot_emerald")),
DIAMOND(new ResourceLocation("item/empty_slot_diamond")),
LAPIS_LAZULI(new ResourceLocation("item/empty_slot_lapis_lazuli")),
AMETHYST_SHARD(new ResourceLocation("item/empty_slot_amethyst_shard")),
RING(new ResourceLocation(AdditionalAdditions.namespace, "item/empty_slot_ring")),
ALLOY(new ResourceLocation(AdditionalAdditions.namespace, "item/empty_slot_alloy"));

final ResourceLocation resourceLocation;

SmithingIcon(ResourceLocation resourceLocation) {
this.resourceLocation = resourceLocation;
}

public ResourceLocation location() {
return resourceLocation;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;

Expand All @@ -27,9 +28,9 @@ public InteractionResultHolder<ItemStack> use(Level world, Player user, Interact
if (!Config.getBool(ConfigValues.MYSTERIOUS_BUNDLE)) { return InteractionResultHolder.fail(user.getItemInHand(hand)); }
if (world.isClientSide()) return InteractionResultHolder.success(user.getItemInHand(hand));
ResourceLocation lootTableID = new ResourceLocation(AdditionalAdditions.namespace, "mysterious_bundle");
LootContext lootContext = (new LootContext.Builder((ServerLevel) world)).withRandom(world.random).create(LootContextParamSets.EMPTY);
LootTable lootTable = ((ServerLevel) world).getServer().getLootTables().get(lootTableID);
List<ItemStack> stackList = lootTable.getRandomItems(lootContext);
LootParams lootParams = (new LootParams.Builder((ServerLevel) world)).create(LootContextParamSets.EMPTY);
LootTable lootTable = ((ServerLevel) world).getServer().getLootData().getLootTable(lootTableID);
List<ItemStack> stackList = lootTable.getRandomItems(lootParams);

for (ItemStack stack : stackList) {
ItemEntity entity = new ItemEntity(world, user.getX(), user.getY(), user.getZ(), stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static boolean hasDisc(ItemStack stack) {
public boolean overrideOtherStackedOnMe(ItemStack stack, ItemStack otherStack, Slot slot, ClickAction clickType, Player player, SlotAccess cursorStackReference) {
if (!Config.getBool(ConfigValues.POCKET_JUKEBOX)) return false;
if (clickType != ClickAction.SECONDARY) return false;
Level world = player.level;
Level world = player.level();

if (nbtGetDisc(stack) == null) {
ItemStack cursor = cursorStackReference.get();
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/dqu/additionaladditions/item/WateringCanItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.FastColor;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
Expand All @@ -19,13 +20,9 @@
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.FarmBlock;
import net.minecraft.world.level.block.GrassBlock;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -73,7 +70,7 @@ public InteractionResultHolder<ItemStack> use(Level world, Player player, Intera
}
}

if (state.getBlock() instanceof BucketPickup fluid && state.getMaterial() == Material.WATER) {
if (state.getBlock() instanceof BucketPickup fluid && state.getBlock() == Blocks.WATER) {
if (stack.getDamageValue() == 100) return InteractionResultHolder.fail(stack);
fluid.getPickupSound().ifPresent((sound) -> player.playSound(sound, 1.0F, 1.0F));
if (!world.isClientSide()) {
Expand All @@ -94,7 +91,7 @@ public boolean isBarVisible(ItemStack stack) {

@Override
public int getBarColor(ItemStack stack) {
return Config.getBool(ConfigValues.WATERING_CAN) ? Mth.color(65, 135, 235) : Mth.color(235, 135, 65);
return Config.getBool(ConfigValues.WATERING_CAN) ? FastColor.ARGB32.color(0, 65, 135, 235) : Mth.color(235, 135, 65);
}

@Override
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/dqu/additionaladditions/misc/LootHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package dqu.additionaladditions.misc;

import dqu.additionaladditions.AdditionalAdditions;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

public class LootHandler {
private static final List<LootEntry> entries = new ArrayList<>();

public static void register(ResourceLocation table, Supplier<Boolean> condition, LootPool.Builder pool) {
LootEntry entry = new LootEntry(table, condition, pool);
entries.add(entry);
}

public static void register(List<ResourceLocation> tables, Supplier<Boolean> condition, LootPool.Builder pool) {
for (ResourceLocation table : tables) {
register(table, condition, pool);
}
}

public static void postInit() {
AdditionalAdditions.LOGGER.info("[" + AdditionalAdditions.namespace + "] Adding " + entries.size() + " loot pools");
}

public static void handle(ResourceLocation id, LootTable.Builder table) {
for (LootEntry entry : entries) {
if (entry.table.equals(id)) {
if (!entry.condition.get()) continue;

table.withPool(entry.pool);
}
}
}

private record LootEntry(
ResourceLocation table,
Supplier<Boolean> condition,
LootPool.Builder pool
) {}
}
2 changes: 1 addition & 1 deletion src/main/java/dqu/additionaladditions/mixin/MobMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void checkDespawn(CallbackInfo ci) {
if (!isFeatureEnabled) return;
if (this.tickCount > 0 || !shouldDespawnInPeaceful()) return;

PoiManager poiManager = ((ServerLevel)level).getPoiManager();
PoiManager poiManager = ((ServerLevel)level()).getPoiManager();
long count = poiManager.getCountInRange(
(poiType) -> {
return poiType.is(AdditionalBlocks.AMETHYST_LAMP_POI_RL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void injectInEatFoodMethod(Level world, ItemStack stack, CallbackInfoR

@Inject(method = "tick", at = @At("TAIL"))
private void applyFireResistance(CallbackInfo ci) {
if (level.isClientSide()) return;
if (this.level().isClientSide()) return;
if (this.isEyeInFluid(FluidTags.LAVA) || this.getRemainingFireTicks() > 0) return;

Float durationPerPiece = Config.get(ConfigValues.GILDED_NETHERITE, "fireResistancePerPiece");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ private void removeRecipes(Map<ResourceLocation, JsonElement> map, ResourceManag
}
if (identifier.getPath().startsWith("gilded_netherite")) {
if (!Config.getBool(ConfigValues.GILDED_NETHERITE, "enabled")) toRemove.add(identifier);
if (Config.getBool(ConfigValues.GOLD_RING)) toRemove.add(identifier);
}
if (identifier.getPath().startsWith("ring_gilded_netherite")) {
if (!Config.getBool(ConfigValues.GILDED_NETHERITE, "enabled")) toRemove.add(identifier);
if (!Config.getBool(ConfigValues.GOLD_RING)) toRemove.add(identifier);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class WanderingTraderMixin {
@Inject(method = "updateTrades", at = @At("RETURN"))
private void addWanderingTraderTrades(CallbackInfo ci) {
MerchantOffers tradeOfferList = ((WanderingTrader) (Object) this).getOffers();
Level world = ((WanderingTrader) (Object) this).level;
Level world = ((WanderingTrader) (Object) this).level();
if (world.getRandom().nextDouble() < 0.5D && Config.getBool(ConfigValues.MYSTERIOUS_BUNDLE)) {
tradeOfferList.add(new MerchantOffer(new ItemStack(Items.EMERALD, 6), new ItemStack(AdditionalItems.MYSTERIOUS_BUNDLE_ITEM, 1), 6, 6, 0.5f));
}
Expand Down
Loading

0 comments on commit 4a1d36f

Please sign in to comment.