Skip to content

Commit

Permalink
port work 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed May 19, 2024
1 parent 4f57108 commit 4d03eec
Show file tree
Hide file tree
Showing 64 changed files with 173 additions and 143 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ int javaVersion = Integer.parseInt(project.java_version)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion

loom {
runs {
client {
vmArgs "-Dfabric-tag-conventions-v1.legacyTagWarning=DEV_VERBOSE"
}
}
}

repositories {
maven { url = "https://maven.gegy.dev/" }
maven { url = "https://maven.terraformersmc.com/releases/" }
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ archives_base_name = bodacious_berries

# mod dependencies
fabric_api_version=0.97.8+1.20.6
emi_version=1.1.6+1.20.2
mod_menu_version=9.0.0
emi_version=1.1.6+1.20.6
mod_menu_version=10.0.0-beta.1

# other dependencies
night_config_version=3.6.6
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
int age = state.get(getAge());
// if the age isn't maximum and the light level is high enough grow the bush
if (age <= maxAge && random.nextInt(GROW_CHANCE) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) {
if (age < maxAge && random.nextInt(GROW_CHANCE) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) {
grow(world, pos, state, age + 1);
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/io/ix0rai/bodacious_berries/block/BerryVine.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;

Expand All @@ -43,10 +42,10 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
builder.add(AGE, UP, NORTH, EAST, SOUTH, WEST);
}

@Override
public boolean hasRandomTicks(BlockState state) {
return state.get(AGE) < MAX_AGE;
}
// @Override
// public boolean hasRandomTicks(BlockState state) {
// return state.get(AGE) < MAX_AGE;
// }

@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
Expand Down Expand Up @@ -104,12 +103,12 @@ public int getMaxBerryAmount() {

@Override
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) {
return this.hasRandomTicks(state);
return state.hasRandomTicks();
}

@Override
public boolean canFertilize(World world, RandomGenerator random, BlockPos pos, BlockState state) {
return this.hasRandomTicks(state);
return state.hasRandomTicks();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.random.RandomGenerator;
Expand All @@ -30,11 +29,6 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
super.appendProperties(builder);
}

@Override
public boolean hasRandomTicks(BlockState state) {
return true;
}

@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
if (Boolean.TRUE.equals(state.get(DYING))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.random.RandomGenerator;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;

Expand Down Expand Up @@ -56,10 +55,10 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
builder.add(getAge()).add(HALF);
}

@Override
public boolean hasRandomTicks(BlockState state) {
return state.get(getAge()) < MAX_AGE;
}
// @Override
// public boolean hasRandomTicks(BlockState state) {
// return state.get(getAge()) < MAX_AGE;
// }

@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
Expand All @@ -72,12 +71,12 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random

@Override
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) {
return hasRandomTicks(state);
return state.hasRandomTicks();
}

@Override
public boolean canFertilize(World world, RandomGenerator random, BlockPos pos, BlockState state) {
return hasRandomTicks(state);
return state.hasRandomTicks();
}

@Override
Expand All @@ -101,13 +100,13 @@ protected ItemInteractionResult onInteract(ItemStack stack, BlockState state, Wo

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hitResult) {
if (hasRandomTicks(state) && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
return ActionResult.PASS;
} else if (state.get(getAge()) == MAX_AGE) {
return BasicBerryBush.pickBerries(pos, world, state, this.getBerryItem());
} else {
// if (hasRandomTicks(state) && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
// return ActionResult.PASS;
// } else if (state.get(getAge()) == MAX_AGE) {
// return BasicBerryBush.pickBerries(pos, world, state, this.getBerryItem());
// } else {
return super.onUse(state, world, pos, player, hitResult);
}
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ protected ItemInteractionResult onInteract(

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity entity, BlockHitResult hitResult) {
// a GrowingBerryBush cannot produce berries until it grows to its double bush state
if (state.hasRandomTicks() && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
final int newAge = Math.min(maxAge, state.get(getAge()) + 1);
// grow to a double bush if new age exceeds maximum
if (newAge > maxAge) {
TallPlantBlock.placeAt(world, futureBush.getDefaultState(), pos, Block.NOTIFY_LISTENERS);
}

return ActionResult.PASS;
}
// // a GrowingBerryBush cannot produce berries until it grows to its double bush state
// if (state.hasRandomTicks() && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
// final int newAge = Math.min(maxAge, state.get(getAge()) + 1);
// // grow to a double bush if new age exceeds maximum
// if (newAge > maxAge) {
// TallPlantBlock.placeAt(world, futureBush.getDefaultState(), pos, Block.NOTIFY_LISTENERS);
// }
//
// return ActionResult.PASS;
// }

return ActionResult.FAIL;
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/io/ix0rai/bodacious_berries/block/JuicerBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.ix0rai.bodacious_berries.block;

import com.mojang.serialization.MapCodec;
import io.ix0rai.bodacious_berries.block.entity.JuicerBlockEntity;
import io.ix0rai.bodacious_berries.registry.BodaciousBlocks;
import net.minecraft.block.Block;
Expand All @@ -14,20 +15,25 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

@SuppressWarnings("deprecation")
public class JuicerBlock extends BlockWithEntity {
public static final BooleanProperty RUNNING = BooleanProperty.of("running");
public static final MapCodec<JuicerBlock> CODEC = createCodec(JuicerBlock::new);

public JuicerBlock(Settings settings) {
super(settings);
this.setDefaultState(this.getDefaultState().with(RUNNING, false));
}

@Override
protected MapCodec<? extends BlockWithEntity> getCodec() {
return CODEC;
}

@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new JuicerBlockEntity(pos, state);
Expand All @@ -44,7 +50,7 @@ public BlockRenderType getRenderType(BlockState state) {
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity entity, BlockHitResult hitResult) {
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hitResult) {
if (!world.isClient) {
// create screen
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.registry.HolderLookup;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.sound.SoundCategory;
Expand All @@ -40,14 +41,13 @@ public BerryHarvesterBlockEntity(BlockPos pos, BlockState state) {
}

@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
Inventories.readNbt(nbt, inventory);
public void method_11014(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
Inventories.readNbt(nbt, inventory, lookupProvider);
}

@Override
public void writeNbt(NbtCompound nbt) {
Inventories.writeNbt(nbt, inventory);
public void writeNbt(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
Inventories.writeNbt(nbt, inventory, lookupProvider);
}

@Override
Expand All @@ -56,8 +56,8 @@ public Packet<ClientPlayPacketListener> toUpdatePacket() {
}

@Override
public NbtCompound toSyncedNbt() {
return toNbt();
public NbtCompound toSyncedNbt(HolderLookup.Provider lookupProvider) {
return toNbt(lookupProvider);
}

public static void tick(World world, BlockPos pos, BlockState state, BerryHarvesterBlockEntity harvester) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeHolder;
import net.minecraft.registry.HolderLookup;
import net.minecraft.screen.ArrayPropertyDelegate;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.PropertyDelegate;
Expand Down Expand Up @@ -66,14 +67,13 @@ public JuicerBlockEntity(BlockPos pos, BlockState state) {
}

@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
Inventories.readNbt(nbt, inventory);
public void method_11014(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
Inventories.readNbt(nbt, inventory, lookupProvider);
}

@Override
public void writeNbt(NbtCompound nbt) {
Inventories.writeNbt(nbt, inventory);
public void writeNbt(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
Inventories.writeNbt(nbt, inventory, lookupProvider);
}

@Override
Expand Down
Loading

0 comments on commit 4d03eec

Please sign in to comment.