Skip to content

Commit

Permalink
1.18.2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Draylar committed Apr 8, 2022
1 parent 6fc3e1a commit 278f100
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 63 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.10-SNAPSHOT'
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'maven-publish'
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.1
loader_version=0.12.11
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.2
loader_version=0.13.3

# Mod Properties
mod_version=1.4.1
mod_version=1.5.0
maven_group=draylar
archives_base_name=go-fish

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.44.0+1.18
fabric_version=0.48.0+1.18.2
11 changes: 1 addition & 10 deletions src/main/java/draylar/gofish/item/SoulLureItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

public class SoulLureItem extends Item implements FishingBonus {

public static final String SOUL_SAND_VALLEY = "minecraft:soul_sand_valley";

public SoulLureItem(Settings settings) {
super(settings);
}
Expand All @@ -41,13 +39,6 @@ public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, Tool

@Override
public boolean shouldApply(World world, PlayerEntity player) {
Identifier id = world.getRegistryManager().get(Registry.BIOME_KEY).getId(world.getBiome(player.getBlockPos()));

if(id != null) {
// todo: make this a constant
return id.toString().equals(SOUL_SAND_VALLEY);
}

return false;
return world.getBiome(player.getBlockPos()).matchesKey(BiomeKeys.SOUL_SAND_VALLEY);
}
}
12 changes: 8 additions & 4 deletions src/main/java/draylar/gofish/loot/WeatherCondition.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
import net.minecraft.loot.context.LootContextParameter;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.util.JsonSerializer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.Set;

Expand All @@ -42,14 +45,15 @@ public LootConditionType getType() {

@Override
public Set<LootContextParameter<?>> getRequiredParameters() {
return ImmutableSet.of();
return ImmutableSet.of(LootContextParameters.THIS_ENTITY, LootContextParameters.ORIGIN);
}

@Override
public boolean test(LootContext lootContext) {
Entity entity = lootContext.get(LootContextParameters.THIS_ENTITY);
@Nullable Entity entity = lootContext.get(LootContextParameters.THIS_ENTITY);
@Nullable Vec3d pos = lootContext.get(LootContextParameters.ORIGIN);

if(entity != null) {
if(entity != null && pos != null) {
World world = entity.world;

// If raining is required and the world is not raining, return false.
Expand All @@ -65,7 +69,7 @@ public boolean test(LootContext lootContext) {
// same check for snowing
if (snowing) {
// >= .15 = no snow
if(world.getBiome(entity.getBlockPos()).getTemperature() >= .15) {
if(world.getBiome(entity.getBlockPos()).value().doesNotSnow(new BlockPos(pos))) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.util.JsonSerializer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;

Expand Down Expand Up @@ -45,7 +46,7 @@ public boolean test(LootContext lootContext) {
Vec3d origin = lootContext.get(LootContextParameters.ORIGIN);

if(origin != null) {
Biome fisherBiome = lootContext.getWorld().getBiome(new BlockPos(origin));
RegistryEntry<Biome> fisherBiome = lootContext.getWorld().getBiome(new BlockPos(origin));

// Category predicate is null, check exact biome
if (category == null || category.getValid().isEmpty()) {
Expand All @@ -56,7 +57,7 @@ public boolean test(LootContext lootContext) {

// Category predicate is not null, check it
else if (!category.getValid().isEmpty()) {
return category.test(fisherBiome.getCategory());
return category.test(Biome.getCategory(fisherBiome));
}
}

Expand Down
18 changes: 8 additions & 10 deletions src/main/java/draylar/gofish/loot/biome/BiomePredicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;

Expand Down Expand Up @@ -35,20 +37,16 @@ public List<String> getValid() {
return valid;
}

public boolean test(World world, Biome biome) {
Identifier id = world.getRegistryManager().get(Registry.BIOME_KEY).getId(biome);

if(id != null) {
String low = id.toString();

for (String s : valid) {
if (new Identifier(s).toString().equals(low)) {
public boolean test(World world, RegistryEntry<Biome> biome) {
return biome.matches(key -> {
for (String entry : valid) {
if (new Identifier(entry).toString().equals(key.toString())) {
return true;
}
}
}

return false;
return false;
});
}

public JsonElement toJson() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.sound.SoundEvents;
import net.minecraft.tag.FluidTags;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -36,7 +37,6 @@
public abstract class FishingBobberLavaFishingMixin extends Entity {

@Shadow public abstract PlayerEntity getPlayerOwner();

@Shadow public abstract void remove(Entity.RemovalReason reason);

private FishingBobberLavaFishingMixin(EntityType<?> type, World world) {
Expand All @@ -46,10 +46,10 @@ private FishingBobberLavaFishingMixin(EntityType<?> type, World world) {
// this mixin is used to determine whether a bobber is actually bobbing for fish
@ModifyVariable(
method = "tick",
at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FluidState;isIn(Lnet/minecraft/tag/Tag;)Z", ordinal = 0),
at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FluidState;isIn(Lnet/minecraft/tag/TagKey;)Z", ordinal = 0),
index = 2
)
private float bobberInLava(float f) {
private float bobberInLava(float value) {
BlockPos blockPos = this.getBlockPos();
FluidState fluidState = this.world.getFluidState(blockPos);

Expand Down Expand Up @@ -78,7 +78,7 @@ private float bobberInLava(float f) {
}

if (canFishInLava) {
f = fluidState.getHeight(this.world, blockPos);
value = fluidState.getHeight(this.world, blockPos);
} else {
if(!getPlayerOwner().isCreative()) {
getPlayerOwner().getStackInHand(rodHand).damage(5, getPlayerOwner(), player -> player.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
Expand All @@ -93,17 +93,17 @@ private float bobberInLava(float f) {
}
}

return f;
return value;
}

// Original check is used to determine whether the bobber should free-fall.
// Bobbers shouldn't free-fall through liquid anyways, so we return true for all liquids.
// note that the original method call is inversed so we also inverse ours
@Redirect(
method = "tick",
at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FluidState;isIn(Lnet/minecraft/tag/Tag;)Z", ordinal = 1)
at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FluidState;isIn(Lnet/minecraft/tag/TagKey;)Z", ordinal = 1)
)
private boolean fallOutsideLiquid(FluidState fluid, Tag<Fluid> tag) {
private boolean fallOutsideLiquid(FluidState fluid, TagKey<Fluid> tag) {
return !fluid.isEmpty();
}

Expand All @@ -112,16 +112,16 @@ private boolean fallOutsideLiquid(FluidState fluid, Tag<Fluid> tag) {
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isOf(Lnet/minecraft/block/Block;)Z", ordinal = 0),
locals = LocalCapture.CAPTURE_FAILHARD
)
private void fishingLavaParticles(BlockPos pos, CallbackInfo ci, ServerWorld serverWorld, int i, float n, float o, float p, double q, double r, double s, BlockState blockState) {
private void fishingLavaParticles(BlockPos pos, CallbackInfo ci, ServerWorld serverWorld, int i, float f, float o, float p, double x, double y, double z, BlockState blockState) {
if (blockState.isOf(Blocks.LAVA)) {
if (this.random.nextFloat() < 0.15F) {
serverWorld.spawnParticles(ParticleTypes.LAVA, q, r - 0.10000000149011612D, s, 1, o, 0.1D, p, 0.0D);
serverWorld.spawnParticles(ParticleTypes.LAVA, x, y - 0.1D, z, 1, o, 0.1D, p, 0.0D);
}

float k = o * 0.04F;
float l = p * 0.04F;
serverWorld.spawnParticles(GoFishParticles.LAVA_FISHING, q, r, s, 0, (double)l, 0.01D, (double)(-k), 1.0D);
serverWorld.spawnParticles(GoFishParticles.LAVA_FISHING, q, r, s, 0, (double)(-l), 0.01D, (double)k, 1.0D);
float dZ = o * 0.04F;
float dX = p * 0.04F;
serverWorld.spawnParticles(GoFishParticles.LAVA_FISHING, x, y, z, 0, dX, 0.01D, (-dZ), 1.0D);
serverWorld.spawnParticles(GoFishParticles.LAVA_FISHING, x, y, z, 0, (-dX), 0.01D, dZ, 1.0D);
}
}

Expand All @@ -130,17 +130,17 @@ private void fishingLavaParticles(BlockPos pos, CallbackInfo ci, ServerWorld ser
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isOf(Lnet/minecraft/block/Block;)Z", ordinal = 1),
locals = LocalCapture.CAPTURE_FAILHARD
)
private void fishSecondaryLavaParticles(BlockPos pos, CallbackInfo ci, ServerWorld serverWorld, int i, float n, float o, float p, double q, double r, double s, BlockState blockState2) {
if (blockState2.isOf(Blocks.LAVA)) {
serverWorld.spawnParticles(ParticleTypes.LAVA, q, r, s, 2 + this.random.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D);
private void fishSecondaryLavaParticles(BlockPos pos, CallbackInfo ci, ServerWorld serverWorld, int i, float f, float g, float h, double x, double y, double z, BlockState blockState) {
if (blockState.isOf(Blocks.LAVA)) {
serverWorld.spawnParticles(ParticleTypes.LAVA, x, y, z, 2 + this.random.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D);
}
}

@Redirect(
method = "getPositionType(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/entity/projectile/FishingBobberEntity$PositionType;",
at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FluidState;isIn(Lnet/minecraft/tag/Tag;)Z")
at = @At(value = "INVOKE", target = "Lnet/minecraft/fluid/FluidState;isIn(Lnet/minecraft/tag/TagKey;)Z")
)
private boolean isInValidLiquid(FluidState fluidState, Tag<Fluid> tag) {
private boolean isInValidLiquid(FluidState fluidState, TagKey<Fluid> tag) {
return !fluidState.isEmpty();
}
}
23 changes: 11 additions & 12 deletions src/main/java/draylar/gofish/registry/GoFishBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import draylar.gofish.block.CrateBlock;
import draylar.gofish.item.CrateItem;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.fabricmc.yarn.constants.MiningLevels;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
Expand All @@ -24,7 +23,7 @@ public class GoFishBlocks {
// Special: enchanting bottle, low-level enchanted book, emerald, bucket / bucket with fish, more materials
// Weapons: damaged crossbows, arrows, bows, stone tools
// Fish: all types of vanilla fish
public static Block WOODEN_CRATE = registerCrate("wooden_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.OAK_WOOD).breakByTool(FabricToolTags.AXES, MiningLevels.WOOD)), new Item.Settings().group(GoFish.GROUP).maxCount(8), GoFish.id("gameplay/fishing/wooden_crate"));
public static Block WOODEN_CRATE = registerCrate("wooden_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.OAK_WOOD)), new Item.Settings().group(GoFish.GROUP).maxCount(8), GoFish.id("gameplay/fishing/wooden_crate"));

// The Iron Crate provides less junk, a chance for iron tools, and better rare loot.
// Junk: Oak Planks, sticks, Oak Logs, String, Seaweed, Kelp, Bones
Expand All @@ -33,21 +32,21 @@ public class GoFishBlocks {
// Special: mid-level enchanted book, emerald, more materials
// Weapons: damaged crossbows, arrows, bows, stone tools
// Fish: all types of vanilla fish
public static Block IRON_CRATE = registerCrate("iron_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).breakByTool(FabricToolTags.PICKAXES, MiningLevels.STONE)), new Item.Settings().group(GoFish.GROUP).maxCount(8), GoFish.id("gameplay/fishing/iron_crate"));
public static Block IRON_CRATE = registerCrate("iron_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)), new Item.Settings().group(GoFish.GROUP).maxCount(8), GoFish.id("gameplay/fishing/iron_crate"));

// The Gold Crate is a rare crate that drops gold items and materials.
public static Block GOLDEN_CRATE = registerCrate("golden_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.GOLD_BLOCK).breakByTool(FabricToolTags.PICKAXES, MiningLevels.IRON)), new Item.Settings().group(GoFish.GROUP).maxCount(8).rarity(Rarity.UNCOMMON), GoFish.id("gameplay/fishing/golden_crate"));
public static Block GOLDEN_CRATE = registerCrate("golden_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.GOLD_BLOCK)), new Item.Settings().group(GoFish.GROUP).maxCount(8).rarity(Rarity.UNCOMMON), GoFish.id("gameplay/fishing/golden_crate"));

// The Diamond Crate provides good materials
public static Block DIAMOND_CRATE = registerCrate("diamond_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).breakByTool(FabricToolTags.PICKAXES, MiningLevels.IRON)), new Item.Settings().group(GoFish.GROUP).maxCount(8).rarity(Rarity.RARE), GoFish.id("gameplay/fishing/diamond_crate"));
public static Block FROSTED_CRATE = registerCrate("frosted_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).breakByTool(FabricToolTags.PICKAXES, MiningLevels.STONE)), new Item.Settings().group(GoFish.GROUP).maxCount(8).rarity(Rarity.RARE), GoFish.id("gameplay/fishing/frosted_crate"));
public static Block DIAMOND_CRATE = registerCrate("diamond_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK)), new Item.Settings().group(GoFish.GROUP).maxCount(8).rarity(Rarity.RARE), GoFish.id("gameplay/fishing/diamond_crate"));
public static Block FROSTED_CRATE = registerCrate("frosted_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.BLUE_ICE)), new Item.Settings().group(GoFish.GROUP).maxCount(8).rarity(Rarity.RARE), GoFish.id("gameplay/fishing/frosted_crate"));
public static Block SLIMEY_CRATE = registerCrate("slimey_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK)), new Item.Settings().group(GoFish.GROUP).maxCount(8), GoFish.id("gameplay/fishing/slimey_crate"));
public static Block SUPPLY_CRATE = registerCrate("supply_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.OAK_WOOD).breakByTool(FabricToolTags.AXES, MiningLevels.WOOD)), new Item.Settings().group(GoFish.GROUP).maxCount(8), GoFish.id("gameplay/fishing/supply_crate"));
public static Block FIERY_CRATE = registerCrate("fiery_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.NETHER_BRICKS).breakByTool(FabricToolTags.PICKAXES, MiningLevels.IRON)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8), GoFish.id("gameplay/fishing/fiery_crate"));
public static Block SOUL_CRATE = registerCrate("soul_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.STONE).breakByTool(FabricToolTags.PICKAXES, MiningLevels.IRON)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.RARE), GoFish.id("gameplay/fishing/soul_crate"));
public static Block GILDED_BLACKSTONE_CRATE = registerCrate("gilded_blackstone_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.GILDED_BLACKSTONE).breakByTool(FabricToolTags.PICKAXES, MiningLevels.IRON)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.UNCOMMON), GoFish.id("gameplay/fishing/gilded_blackstone_crate"));
public static Block ASTRAL_CRATE = registerCrate("astral_crate", new AstralCrateBlock(FabricBlockSettings.copyOf(Blocks.END_STONE).breakByTool(FabricToolTags.PICKAXES, MiningLevels.IRON).nonOpaque()), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.EPIC), GoFish.id("gameplay/fishing/astral_crate"));
public static Block END_CRATE = registerCrate("end_crate", new AstralCrateBlock(FabricBlockSettings.copyOf(Blocks.END_STONE).breakByTool(FabricToolTags.PICKAXES, MiningLevels.DIAMOND)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.EPIC), GoFish.id("gameplay/fishing/end_crate"));
public static Block SUPPLY_CRATE = registerCrate("supply_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.OAK_WOOD)), new Item.Settings().group(GoFish.GROUP).maxCount(8), GoFish.id("gameplay/fishing/supply_crate"));
public static Block FIERY_CRATE = registerCrate("fiery_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.NETHER_BRICKS)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8), GoFish.id("gameplay/fishing/fiery_crate"));
public static Block SOUL_CRATE = registerCrate("soul_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.STONE)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.RARE), GoFish.id("gameplay/fishing/soul_crate"));
public static Block GILDED_BLACKSTONE_CRATE = registerCrate("gilded_blackstone_crate", new CrateBlock(FabricBlockSettings.copyOf(Blocks.GILDED_BLACKSTONE)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.UNCOMMON), GoFish.id("gameplay/fishing/gilded_blackstone_crate"));
public static Block ASTRAL_CRATE = registerCrate("astral_crate", new AstralCrateBlock(FabricBlockSettings.copyOf(Blocks.END_STONE).nonOpaque()), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.EPIC), GoFish.id("gameplay/fishing/astral_crate"));
public static Block END_CRATE = registerCrate("end_crate", new AstralCrateBlock(FabricBlockSettings.copyOf(Blocks.END_STONE)), new Item.Settings().group(GoFish.GROUP).fireproof().maxCount(8).rarity(Rarity.EPIC), GoFish.id("gameplay/fishing/end_crate"));

public static <T extends Block> T register(String name, T block) {
return Registry.register(Registry.BLOCK, GoFish.id(name), block);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"gofish:supply_crate",
"gofish:wooden_crate"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"replace": false,
"values": [
"gofish:iron_crate",
"gofish:golden_crate",
"gofish:diamond_crate",
"gofish:frosted_crate",
"gofish:fiery_crate",
"gofish:soul_crate",
"gofish:gilded_blackstone_crate",
"gofish:astral_crate",
"gofish:end_crate"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"gofish:end_crate"
]
}
11 changes: 11 additions & 0 deletions src/main/resources/data/minecraft/tags/items/needs_iron_tool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"replace": false,
"values": [
"gofish:golden_crate",
"gofish:diamond_crate",
"gofish:fiery_crate",
"gofish:soul_crate",
"gofish:astral_crate",
"gofish:gilded_blackstone_crate"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"gofish:iron_crate",
"gofish:frosted_crate"
]
}
2 changes: 1 addition & 1 deletion src/main/resources/go-fish.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "draylar.gofish.mixin",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_17",
"mixins": [
"FishingBobberAutosmeltMixin",
"FishingBobberEntityAccessor",
Expand Down

0 comments on commit 278f100

Please sign in to comment.