Skip to content

Commit

Permalink
change filewriter
Browse files Browse the repository at this point in the history
  • Loading branch information
yurisuika committed Oct 28, 2024
1 parent 0a898ee commit 3fe747e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/main/java/dev/yurisuika/blossom/util/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.io.File;
import java.io.FileWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

public class Config {
Expand All @@ -25,7 +26,7 @@ public static void setOptions(Options options) {

public static void saveConfig() {
try {
FileWriter fileWriter = new FileWriter(file);
FileWriter fileWriter = new FileWriter(file, StandardCharsets.UTF_8);
fileWriter.write(gson.toJson(getOptions()));
fileWriter.close();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraft.util.ParticleUtils;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -122,7 +122,7 @@ public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random
if (level.isRaining() && precipitation == Precipitation.RAIN) {
f = 5.0F;
}
if (random.nextInt((int)(25.0F / f) + 1) == 0) {
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
level.setBlock(pos, defaultBlockState().setValue(AGE, i + 1)
.setValue(DISTANCE, state.getValue(DISTANCE))
.setValue(PERSISTENT, state.getValue(PERSISTENT))
Expand Down Expand Up @@ -248,7 +248,7 @@ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos
applyGrowth(level, pos, state);
}

public InteractionResult useItemOn(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
public ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack itemStack = player.getItemInHand(hand);
Item item = itemStack.getItem();
if (item instanceof ShearsItem) {
Expand All @@ -263,9 +263,9 @@ public InteractionResult useItemOn(BlockState state, Level level, BlockPos pos,
.setValue(PERSISTENT, state.getValue(PERSISTENT))
.setValue(WATERLOGGED, state.getValue(WATERLOGGED))
);
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
} else {
return InteractionResult.PASS;
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -125,7 +125,7 @@ public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random
if (level.isRaining() && precipitation == Precipitation.RAIN) {
f = 5.0F;
}
if (random.nextInt((int)(25.0F / f) + 1) == 0) {
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
level.setBlock(pos, defaultBlockState().setValue(AGE, i + 1)
.setValue(DISTANCE, state.getValue(DISTANCE))
.setValue(PERSISTENT, state.getValue(PERSISTENT))
Expand Down Expand Up @@ -255,7 +255,7 @@ public static void dropFruit(Level level, BlockPos pos, Item item, int bonus) {
popResource(level, pos, new ItemStack(item, count));
}

public InteractionResult useItemOn(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
public ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack itemStack = player.getItemInHand(hand);
if (isMaxAge(state)) {
Item item = itemStack.getItem();
Expand All @@ -273,9 +273,9 @@ public InteractionResult useItemOn(BlockState state, Level level, BlockPos pos,
.setValue(WATERLOGGED, state.getValue(WATERLOGGED))
);
}
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
} else {
return InteractionResult.PASS;
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/blossom.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"minVersion": "0.8",
"package": "dev.yurisuika.blossom.mixin",
"refmap": "blossom.refmap.json",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
"world.entity.EntityAccessor",
"world.entity.MobAccessor",
Expand Down

0 comments on commit 3fe747e

Please sign in to comment.