Skip to content

Commit

Permalink
1.19 port
Browse files Browse the repository at this point in the history
  • Loading branch information
frqnny committed Aug 2, 2022
1 parent c0d5d2e commit 95150b6
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 45 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import groovy.json.JsonOutput
import groovy.json.JsonSlurper

plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -24,7 +24,6 @@ dependencies {
modImplementation include("io.github.cottonmc:LibGui:${project.libgui_version}")

modImplementation include("com.github.Draylar.omega-config:omega-config-base:${project.config_version}")
modRuntimeOnly("com.terraformersmc:modmenu:${project.mod_menu_version}")

}
repositories {
Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ org.gradle.jvmargs=-Xmx3G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.13.3
minecraft_version=1.19.1
yarn_mappings=1.19.1+build.5
loader_version=0.14.8

#Fabric api
fabric_version=0.51.1+1.18.2
fabric_version=0.58.5+1.19.1

# Dependencies
libgui_version=5.4.0+1.18.2
libgui_version=6.0.0+1.19
config_version=1.2.3-1.18.1
mod_menu_version=3.0.1
# Mod Properties
mod_version = 1.0.0+1.18.2
mod_version = 1.0.0+1.19.1
maven_group = io.github.frqnny
archives_base_name = dark-enchanting
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;

import java.util.Random;

public class DarkConduitBlock extends TorchBlock {
public static final Identifier ID = new Identifier(DarkEnchanting.MODID, "dark_conduit");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.Random;

public class DarkEnchanterBlock extends BlockWithEntity {
public static final Identifier ID = new Identifier(DarkEnchanting.MODID, "dark_enchanter");
public static final EnumProperty<BookType> BOOK_TYPE = EnumProperty.of("book_type", BookType.class);
Expand Down Expand Up @@ -73,8 +72,8 @@ public boolean hasSidedTransparency(BlockState blockState_1) {

@Environment(EnvType.CLIENT)
@Override
public void randomDisplayTick(BlockState state, World world, BlockPos blockPos, Random random) {
super.randomDisplayTick(state, world, blockPos, random);
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
super.randomDisplayTick(state, world, pos, random);

//inner circle
for (int x = -2; x <= 2; ++x) {
Expand All @@ -86,13 +85,13 @@ public void randomDisplayTick(BlockState state, World world, BlockPos blockPos,

if (random.nextInt(16) == 0) {
for (int y = 0; y <= 1; ++y) {
BlockPos blockPos_2 = blockPos.add(x, y, z);
BlockPos blockPos_2 = pos.add(x, y, z);
if (world.getBlockState(blockPos_2).getBlock() == Blocks.BOOKSHELF) {
if (!world.isAir(blockPos.add(x / 2, 0, z / 2))) {
if (!world.isAir(pos.add(x / 2, 0, z / 2))) {
break;
}

world.addParticle(ParticleTypes.ENCHANT, (double) blockPos.getX() + 0.5D, (double) blockPos.getY() + 2.0D, (double) blockPos.getZ() + 0.5D, (double) ((float) x + random.nextFloat()) - 0.5D, (float) y - random.nextFloat() - 1.5F, (double) ((float) z + random.nextFloat()) - 0.5D);
world.addParticle(ParticleTypes.ENCHANT, (double) pos.getX() + 0.5D, (double) pos.getY() + 2.0D, (double) pos.getZ() + 0.5D, (double) ((float) x + random.nextFloat()) - 0.5D, (float) y - random.nextFloat() - 1.5F, (double) ((float) z + random.nextFloat()) - 0.5D);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;

Expand All @@ -28,7 +27,7 @@ public void writeScreenOpeningData(ServerPlayerEntity serverPlayerEntity, Packet

@Override
public Text getDisplayName() {
return new TranslatableText("block.dark-enchanting.dark_enchanter");
return Text.translatable("block.dark-enchanting.dark_enchanter");
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.registry.Registry;

Expand Down Expand Up @@ -71,11 +69,11 @@ public DarkEnchanterGUI(int syncId, PlayerInventory playerInventory, ScreenHandl
root.add(scrollPanel, 65, 17, 150, 135);

root.add(enchantButton, 35, 60, 20, 20);
enchantButton.setLabel(new LiteralText("E"));
enchantButton.setLabel(Text.literal("E"));
enchantButton.setOnClick(this::enchant);

root.add(repairButton, 35, 85, 20, 20);
repairButton.setLabel(new LiteralText("R"));
repairButton.setLabel(Text.literal("R"));
repairButton.setOnClick(this::repair);

WDynamicTooltipLabel tooltip = new WDynamicTooltipLabel(this::getTooltip);
Expand All @@ -86,7 +84,7 @@ public DarkEnchanterGUI(int syncId, PlayerInventory playerInventory, ScreenHandl
}

public Text getLabel(Enchantment enchantment, int level) {
MutableText mutableText = new TranslatableText(enchantment.getTranslationKey());
MutableText mutableText = Text.translatable(enchantment.getTranslationKey());
if (enchantment.isCursed()) {
mutableText.formatted(Formatting.RED);
} else if (enchantment.isTreasure()) {
Expand All @@ -96,7 +94,7 @@ public Text getLabel(Enchantment enchantment, int level) {
}

if (level > 0) {
mutableText.append(" ").append(new TranslatableText("enchantment.level." + level));
mutableText.append(" ").append(Text.translatable("enchantment.level." + level));
}

return mutableText;
Expand Down Expand Up @@ -282,21 +280,21 @@ public List<Text> getTooltip() {
}

return ImmutableList.of(
new LiteralText("Enchant Cost:").formatted(Formatting.DARK_GREEN),
new LiteralText(string),
new LiteralText(""),
new LiteralText(""),
new LiteralText("Repair Cost:").formatted(Formatting.BLUE),
new LiteralText("Pay: " + DarkEnchanterGUI.this.repairCost + " XP"),
new LiteralText(""),
new LiteralText(""),
new LiteralText("Bookshelf Discount:").formatted(Formatting.DARK_PURPLE),
new LiteralText(DarkEnchanterGUI.this.bookcaseStats1 + DarkEnchanterGUI.this.bookcaseStats2 + DarkEnchanterGUI.this.bookcaseStats3 + " " + DarkEnchanterGUI.this.bookshelfDiscount + " %"),
new LiteralText(""),
new LiteralText(""),
new LiteralText("You have: " + PlayerUtils.getTotalExperience(DarkEnchanterGUI.this.playerInventory.player) + " XP").formatted(Formatting.GOLD),
new LiteralText(""),
new LiteralText(""));
Text.literal("Enchant Cost:").formatted(Formatting.DARK_GREEN),
Text.literal(string),
Text.literal(""),
Text.literal(""),
Text.literal("Repair Cost:").formatted(Formatting.BLUE),
Text.literal("Pay: " + DarkEnchanterGUI.this.repairCost + " XP"),
Text.literal(""),
Text.literal(""),
Text.literal("Shrine Discount:").formatted(Formatting.DARK_PURPLE),
Text.literal(DarkEnchanterGUI.this.bookcaseStats1 + DarkEnchanterGUI.this.bookcaseStats2 + DarkEnchanterGUI.this.bookcaseStats3 + " " + DarkEnchanterGUI.this.bookshelfDiscount + " %"),
Text.literal(""),
Text.literal(""),
Text.literal("You have: " + PlayerUtils.getTotalExperience(DarkEnchanterGUI.this.playerInventory.player) + " XP").formatted(Formatting.GOLD),
Text.literal(""),
Text.literal(""));
}

public void onStackUpdate(ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
Expand All @@ -33,14 +33,14 @@ public ActionResult useOnBlock(ItemUsageContext context) {
context.getStack().decrement(1);
return ActionResult.SUCCESS;
} else {
context.getPlayer().sendMessage(new TranslatableText("message.dark-enchanting.table_upgrade"), true);
context.getPlayer().sendMessage(Text.translatable("message.dark-enchanting.table_upgrade"), true);
}
return ActionResult.PASS;
}

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
user.sendMessage(new TranslatableText("message.dark-enchanting.table_upgrade"), true);
user.sendMessage(Text.translatable("message.dark-enchanting.table_upgrade"), true);
return super.use(world, user, hand);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
},
"depends": {
"libgui": "*",
"minecraft": "1.18.x"
"minecraft": "1.19.x"
}
}

0 comments on commit 95150b6

Please sign in to comment.