Skip to content

Commit

Permalink
fix recipes, chorus berry juice and eating juice
Browse files Browse the repository at this point in the history
  • Loading branch information
orifu committed Nov 8, 2024
1 parent 84b48e3 commit 9952465
Show file tree
Hide file tree
Showing 45 changed files with 140 additions and 368 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
import net.minecraft.block.Blocks;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ConsumeEffect;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Holder;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionTypes;

import java.util.Optional;
import java.util.Set;

public class ChorusBerryJuice extends Juice {
private final Identifier biome;
Expand All @@ -26,24 +29,20 @@ public ChorusBerryJuice(BlockItem berry, Identifier biome) {
this.biome = biome;
}

/* @Override
@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
// teleport user to biome specified in constructor
// the biome can be null, in which case the user will not be teleported
boolean success = false;

if (biome != null && world.getServer() != null) {
MinecraftServer server = world.getServer();
// ensure we are in the overworld
if (world.getDimension().equals(server.getRegistryManager().get(RegistryKeys.DIMENSION_TYPE).get().getValue().get(DimensionTypes.OVERWORLD_ID))) {
// locate the biome to teleport to
Pair<BlockPos, Boolean> pair = locateBiome(server, user.getBlockPos(), user);
BlockPos pos = pair.getFirst();
success = pair.getSecond();
if (biome != null && world instanceof ServerWorld serverWorld) {
MinecraftServer server = serverWorld.getServer();
// locate the biome to teleport to
Optional<BlockPos> pos = locateBiome(server, serverWorld, user.getBlockPos());

if (success) {
safeTeleport(pos, world, user);
}
if (pos.isPresent()) {
safeTeleport(pos.get(), serverWorld, user);
success = true;
}
}

Expand All @@ -52,48 +51,37 @@ public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {

// consume item
return super.finishUsing(stack, world, user);
} */
}

private void safeTeleport(BlockPos pos, World world, LivingEntity user) {
private void safeTeleport(BlockPos pos, ServerWorld world, LivingEntity user) {
do {
pos = pos.up();
} while ((!world.getBlockState(pos).getBlock().equals(Blocks.AIR)
&& !world.getBlockState(pos.up()).getBlock().equals(Blocks.AIR))
|| pos.getY() == world.getHeight());

user.requestTeleportAndDismount(pos.getX(), pos.getY(), pos.getZ());
user.teleport(world, pos.getX(), pos.getY(), pos.getZ(), Set.of(), 90, 0, true);
SoundEvent soundEvent = SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
user.playSound(soundEvent, 1.0F, 1.0F);
world.playSound(null, user.getBlockPos(), soundEvent, SoundCategory.PLAYERS, 1.0F, 1.0F);
}

private Pair<BlockPos, Boolean> locateBiome(MinecraftServer server, BlockPos pos, LivingEntity user) {
Holder<Biome> biome = Holder.createDirect(server.getRegistryManager().get(RegistryKeys.BIOME).get().getValue().get(this.biome));
private Optional<BlockPos> locateBiome(MinecraftServer server, ServerWorld world, BlockPos pos) {
Holder.Reference<Biome> biome = server.getRegistryManager().getLookup(RegistryKeys.BIOME).orElseThrow()
.getHolder(RegistryKey.of(RegistryKeys.BIOME, this.biome)).orElseThrow();

Pair<BlockPos, Holder<Biome>> pair = server.getOverworld().locateBiome(
Pair<BlockPos, Holder<Biome>> pair = world.locateBiome(
biome::equals,
user.getBlockPos(),
pos,
6400,
8,
10
64,
128
);

if (pair != null) {
return Pair.of(pair.getFirst(), true);
return Optional.of(pair.getFirst());
} else {
return Pair.of(pos, false);
}
}

public record TeleportToBiomeEffect(Identifier biome) implements ConsumeEffect {
@Override
public Type<? extends ConsumeEffect> method_62864() {
return null;
}

@Override
public boolean method_62866(World world, ItemStack stack, LivingEntity entity) {
return false;
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.ix0rai.bodacious_berries.registry;

import io.ix0rai.bodacious_berries.BodaciousBerries;
import io.ix0rai.bodacious_berries.block.BasicBerryBush;
import io.ix0rai.bodacious_berries.block.BerryBush;
import io.ix0rai.bodacious_berries.block.BerryVine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.unmapped.C_pmcnnsvg;
import net.minecraft.unmapped.C_uaiigijw;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -70,14 +69,14 @@ private static void registerBlends() {
register(new GojiBerryBlend(JUICE_SETTINGS.food(
new FoodComponent.Builder().hunger(5).saturation(1.8F).build(),
C_uaiigijw.method_62859().method_62854(new C_pmcnnsvg(new StatusEffectInstance(StatusEffects.GLOWING, 800, 1), 1.0F)).method_62851())));
register(new Juice("opposite_juice", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(4).saturation(1.2F).build())));
register(new Juice("rainberry_blend", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(6).saturation(1.6F).build())));
register(new Juice("gooseberry_rum", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(7).saturation(1.0f).build())));
register(new Juice("red_juice", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(5).saturation(1.3F).build())));
register(new EndBlend(JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(3).saturation(3.3F).build())));
register(new Juice("purple_delight", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(6).saturation(1.6F).build())));
register(new Juice("traffic_light_juice", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(5).saturation(1.4F).build())));
register(new Juice("vanilla_delight", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(4).saturation(2.0F).build())));
register(new Juice("opposite_juice", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(4).saturation(1.2F).build(), C_uaiigijw.method_62859().method_62851())));
register(new Juice("rainberry_blend", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(6).saturation(1.6F).build(), C_uaiigijw.method_62859().method_62851())));
register(new Juice("gooseberry_rum", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(7).saturation(1.0f).build(), C_uaiigijw.method_62859().method_62851())));
register(new Juice("red_juice", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(5).saturation(1.3F).build(), C_uaiigijw.method_62859().method_62851())));
register(new EndBlend(JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(3).saturation(3.3F).build(), C_uaiigijw.method_62859().method_62851())));
register(new Juice("purple_delight", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(6).saturation(1.6F).build(), C_uaiigijw.method_62859().method_62851())));
register(new Juice("traffic_light_juice", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(5).saturation(1.4F).build(), C_uaiigijw.method_62859().method_62851())));
register(new Juice("vanilla_delight", JUICE_SETTINGS.food(new FoodComponent.Builder().hunger(4).saturation(2.0F).build(), C_uaiigijw.method_62859().method_62851())));
}

private static void register(Juice juice) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@
"iOi"
],
"key": {
"#": {
"item": "minecraft:cobblestone"
},
"O": {
"tag": "minecraft:planks"
},
"S": {
"item": "minecraft:shears"
},
"i": {
"item": "minecraft:iron_ingot"
}
"#": "minecraft:cobblestone",
"O": "#minecraft:planks",
"S": "minecraft:shears",
"i": "minecraft:iron_ingot"
},
"result": {
"id": "bodacious_berries:berry_harvester",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/blackberries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/blackberries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:blackberry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/chorus_berries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/chorus_berries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:chorus_berry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/cloudberries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/cloudberries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:cloudberry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/glow_berries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/glow_berries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:glow_berry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/goji_berries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/goji_berries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:goji_berry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/gooseberries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/gooseberries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:gooseberry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/saskatoon_berries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/saskatoon_berries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:grape_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/lingonberries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/lingonberries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:lingonberry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/rainberries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/rainberries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:rainberry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/raspberries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/raspberries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:raspberry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/saskatoon_berries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/saskatoon_berries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:saskatoon_berry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/strawberries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/strawberries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:strawberry_juice"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"type": "bodacious_berries:juicing",
"ingredients": {
"all": {
"tag": "c:foods/sweet_berries"
},
"receptacle": {
"item": "minecraft:glass_bottle"
}
"all": "#c:foods/sweet_berries",
"receptacle": "minecraft:glass_bottle"
},
"result": "bodacious_berries:sweet_berry_juice"
}
Loading

0 comments on commit 9952465

Please sign in to comment.