Skip to content

Commit

Permalink
initial 1.20.6+polymer port
Browse files Browse the repository at this point in the history
  • Loading branch information
unix-supremacist committed Jun 11, 2024
1 parent 677fbb1 commit c784ff3
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 159 deletions.
40 changes: 21 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -32,6 +32,7 @@ repositories {
maven {
url = 'https://maven.ladysnake.org/releases'
}
maven { url = "https://maven.nucleoid.xyz" }
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
Expand Down Expand Up @@ -77,35 +78,36 @@ sourceSets {
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
//parchment("org.parchmentmc.data:parchment-1.20.1:2023.06.26@zip")
}
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
include modImplementation("io.github.feltmc:felt-splash-api:1.0.0"){
exclude(group: "com.terraformersmc")
}
include modImplementation("io.github.feltmc:felt-tool-api:1.0.0"){
exclude(group: "com.terraformersmc")
}
modRuntimeOnly "maven.modrinth:modmenu:${project.modmenu_version}"
//include modImplementation("io.github.feltmc:felt-tool-api:1.0.0"){
// exclude(group: "com.terraformersmc")
//}
//modRuntimeOnly "maven.modrinth:modmenu:${project.modmenu_version}"
modImplementation "io.github.ladysnake:PlayerAbilityLib:1.9.0"
//required for trinkets
modRuntimeOnly "dev.onyxstudios.cardinal-components-api:cardinal-components-base:5.3.0"
modRuntimeOnly "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:5.3.0"
modImplementation "dev.emi:trinkets:3.8.0"
modRuntimeOnly "maven.modrinth:jei:16.0.0.28"
modRuntimeOnly "dev.onyxstudios.cardinal-components-api:cardinal-components-base:6.0.0-beta.3"
modRuntimeOnly "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:6.0.0-beta.3"
modImplementation "eu.pb4.polyport:trinkets:3.9.0+polymerport.1"
modImplementation include("eu.pb4:polymer-core:0.8.3+1.20.6")
modImplementation include("eu.pb4:polymer-virtual-entity:0.8.3+1.20.6")
modImplementation include("eu.pb4:polymer-resource-pack:0.8.3+1.20.6")
modImplementation include("eu.pb4:factorytools:0.2.2+1.20.6")
//modRuntimeOnly "maven.modrinth:jei:16.0.0.28"
//modRuntimeOnly "maven.modrinth:architectury-api:10.0.7+fabric"
//modRuntimeOnly "maven.modrinth:cloth-config:12.0.107+fabric"
//modRuntimeOnly "maven.modrinth:rei:13.0.654+fabric"
modRuntimeOnly "maven.modrinth:modernfix:${project.modernfix_version}"
//modRuntimeOnly "maven.modrinth:modernfix:${project.modernfix_version}"
//modRuntimeOnly "maven.modrinth:ferrite-core:6.0.0-fabric"
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'

testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
testCompileOnly 'org.projectlombok:lombok:1.18.32'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
}

processResources {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10

# Mod Properties
mod_version=1.0.0
Expand All @@ -15,7 +15,7 @@ maven_group=com.example
archives_base_name=alchemist

# Dependencies
fabric_version=0.89.2+1.20.2
fabric_version=0.100.0+1.20.6

#Env
modernfix_version = 5.7.3-beta.1+mc1.20.2-pre3
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@
import org.lwjgl.glfw.GLFW;

public class AlchemistClient implements ClientModInitializer {
static boolean run = true;
@Override
public void onInitializeClient() {
KeyMapping empower = KeyBindingHelper.registerKeyBinding(new KeyMapping("key.alchemist.empower", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_V, "key.categories.alchemist"));
BlockRenderLayerMap.INSTANCE.putBlock(AlchemistBlocks.transmutation_circle.getBlock(), RenderType.cutout());

ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (empower.consumeClick()) ClientPlayNetworking.send(Alchemist.empower_packet, PacketByteBufs.empty());
});
}
}
25 changes: 14 additions & 11 deletions src/main/java/io/github/unix_supremacist/Alchemist.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package io.github.unix_supremacist;

import com.mojang.serialization.Codec;
import eu.pb4.polymer.core.api.item.PolymerItemGroupUtils;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import io.github.unix_supremacist.content.AlchemistBlocks;
import io.github.unix_supremacist.content.AlchemistItems;
import io.github.unix_supremacist.content.AlchemistSplashes;
import io.github.unix_supremacist.data.BlockTag;
import io.github.unix_supremacist.item.AbstractEmpowerableItem;
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.core.Registry;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -23,27 +26,27 @@ public class Alchemist {
public static final String MODID = "alchemist";
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
public static final ResourceLocation empower_packet = new ResourceLocation(Alchemist.MODID, "empower_packet");
public static final CreativeModeTab tab = FabricItemGroup.builder()
public static final CreativeModeTab tab = PolymerItemGroupUtils.builder()
.icon(() -> new ItemStack(AlchemistItems.philosophers_stone.getItem()))
.title(Component.translatable("itemGroup."+MODID))
.build();
//public static final DataComponentType<Integer> POWER = DataComponents.register("alchemist.empowered", builder -> builder.persistent(ExtraCodecs.NON_NEGATIVE_INT).networkSynchronized(ByteBufCodecs.VAR_INT));
//public static final DataComponentType<Integer> POWER = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, "alchemist.empowered", ((DataComponentType.Builder)builder -> builder.persistent(ExtraCodecs.NON_NEGATIVE_INT).networkSynchronized(ByteBufCodecs.VAR_INT).apply(DataComponentType.builder())).build());
public static final DataComponentType<Integer> POWER = DataComponentType.<Integer>builder().persistent(ExtraCodecs.NON_NEGATIVE_INT).networkSynchronized(ByteBufCodecs.VAR_INT).build();




public static void Init(){
LOGGER.info("Welcome to the World of Alchemy!");
Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, new ResourceLocation(MODID, "empowered"), POWER);
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation(MODID, "tab"), tab);
AlchemistSplashes.init();
AlchemistBlocks.values(); //force the enum to load
AlchemistItems.values(); //force the enum to load
CommonLifecycleEvents.TAGS_LOADED.register((registries, client) -> {
BlockTag.init();
});
ServerPlayNetworking.registerGlobalReceiver(empower_packet, (server, player, handler, buf, responseSender) -> {
ItemStack item = player.getMainHandItem();
if(item.getItem() instanceof AbstractEmpowerableItem){
((AbstractEmpowerableItem) item.getItem()).empower(item, player);
}
});
PolymerResourcePackUtils.addModAssets(MODID);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package io.github.unix_supremacist.block;

import eu.pb4.polymer.core.api.block.SimplePolymerBlock;
import io.github.unix_supremacist.interfaces.TransmuteEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.entity.npc.Villager;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
Expand All @@ -20,24 +19,24 @@

import java.util.List;

public class TransmutionCircleBlock extends Block implements TransmuteEntity {
public class TransmutionCircleBlock extends SimplePolymerBlock implements TransmuteEntity {
public TransmutionCircleBlock(Properties properties) {
super(properties);
super(properties, Blocks.TRIPWIRE);
}

@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (!level.isClientSide()) {
AABB aABB = new AABB(pos);
List<Villager> villagerList = level.getEntitiesOfClass(Villager.class, aABB);
if(!villagerList.isEmpty()){
level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
return transmuteEntity(villagerList.get(0), level);
}
}
@Override
public InteractionResult useWithoutItem(BlockState blockState, Level level, BlockPos pos, Player player, BlockHitResult blockHitResult) {
if (!level.isClientSide()) {
AABB aABB = new AABB(pos);
List<Villager> villagerList = level.getEntitiesOfClass(Villager.class, aABB);
if(!villagerList.isEmpty()){
level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
return transmuteEntity(villagerList.get(0), level);
}
}

return InteractionResult.PASS;
}
return InteractionResult.PASS;
}

@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.unix_supremacist.content;

import eu.pb4.polymer.core.api.block.SimplePolymerBlock;
import io.github.unix_supremacist.Alchemist;
import io.github.unix_supremacist.block.TransmutionCircleBlock;
import lombok.Getter;
Expand All @@ -11,9 +12,10 @@

public enum AlchemistBlocks {
transmutation_circle(new TransmutionCircleBlock(FabricBlockSettings.create()));
@Getter Block block;
@Getter
SimplePolymerBlock block;

AlchemistBlocks(Block block){
AlchemistBlocks(SimplePolymerBlock block){
this.block = block;
Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Alchemist.MODID, this.name()), block);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.unix_supremacist.content;

import eu.pb4.factorytools.api.item.ModeledItem;
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
import io.github.unix_supremacist.Alchemist;
import io.github.unix_supremacist.item.ChalkItem;
import io.github.unix_supremacist.item.DestructionItem;
Expand All @@ -14,47 +16,41 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Item.Properties;
import net.minecraft.world.item.Items;

public enum AlchemistItems {
alchemical_coal(6400),
alchemical_coal(6400, Items.DIAMOND),
//archangels_smite,
//black_hole_band,
catalytic_lens(new DestructionItem(new Properties().stacksTo(1), 3, 10, 5)),
catalytic_lens(new DestructionItem(new Properties().stacksTo(1), 3, 10, 5, Items.GOLD_NUGGET)),
chalk(new ChalkItem(AlchemistBlocks.transmutation_circle.getBlock(), new Properties().durability(64))),
dark_matter,
dark_matter(0, Items.FIRE_CHARGE),
//dark_matter_pickaxe,
//dark_matter_shovel,
//dark_matter_hoe,
//dark_matter_sword,
//dark_matter_axe,
//dark_matter_shears,
//dark_matter_hammer,
destruction_catalyst(new DestructionItem(new Properties().stacksTo(1), 3, 5, 1)),
destruction_catalyst(new DestructionItem(new Properties().stacksTo(1), 3, 5, 1, Items.GOLD_INGOT)),
//evertide_amulet,
//gem_of_eternal_density,
//harvest_goddess_band,
//hyperkinetic_lens,
iron_band,
mobius_fuel(25600),
iron_band(0, Items.IRON_BARS),
mobius_fuel(25600, Items.EMERALD),
philosophers_stone(new PhilosophersStoneItem(new Properties().stacksTo(1))),
swiftwolfs_rending_gale(new GaleItem(new Properties().stacksTo(1))),
//volcanite_amulet,
;
@Getter Item item;
AlchemistItems(){
this(0);
}

AlchemistItems(int burntime){
this(new Properties(), burntime);
}

AlchemistItems(Properties properties){
this(new Item(properties), 0);
AlchemistItems(int burntime, Item polymerItem){
this(new Properties(), burntime, polymerItem);
}

AlchemistItems(Properties properties, int burntime){
this(new Item(properties), burntime);
AlchemistItems(Properties properties, int burntime, Item polymerItem){
this(new ModeledItem(polymerItem, properties), burntime);
}

AlchemistItems(Item item){
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/io/github/unix_supremacist/data/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
import io.github.unix_supremacist.content.AlchemistItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import org.apache.commons.lang3.text.WordUtils;

import java.util.concurrent.CompletableFuture;


public class Language extends FabricLanguageProvider {
protected Language(FabricDataOutput dataOutput) {
super(dataOutput, "en_us");
protected Language(FabricDataOutput dataOutput, CompletableFuture<HolderLookup.Provider> registryLookup) {
super(dataOutput, registryLookup);
}

@Override
public void generateTranslations(TranslationBuilder translationBuilder) {
public void generateTranslations(HolderLookup.Provider registryLookup, TranslationBuilder translationBuilder) {
for (AlchemistItems item : AlchemistItems.values())
translationBuilder.add(item.getItem(), WordUtils.capitalize(item.name().replace("_", " ")));

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/io/github/unix_supremacist/data/Recipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
import io.github.unix_supremacist.Alchemist;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.recipes.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;

import java.util.concurrent.CompletableFuture;

import static io.github.unix_supremacist.content.AlchemistItems.*;

public class Recipe extends FabricRecipeProvider {
public Recipe(FabricDataOutput generator) {
super(generator);
public Recipe(FabricDataOutput generator, CompletableFuture<HolderLookup.Provider> registriesFuture) {
super(generator, registriesFuture);
}

@Override
Expand Down
Loading

0 comments on commit c784ff3

Please sign in to comment.