Skip to content

Commit

Permalink
1.21 Port
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Jun 23, 2024
1 parent 10e781d commit d38aa65
Show file tree
Hide file tree
Showing 101 changed files with 521 additions and 640 deletions.
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ dependencies {
}

processResources {
inputs.property "version", project.version
def version = project.version
inputs.property "version", version

filesMatching("META-INF/mods.toml") {
expand "version": project.version
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": version
}
}

Expand Down Expand Up @@ -257,9 +258,9 @@ if (System.getenv("CURSEFORGE_API_KEY") && !version.endsWith("-SNAPSHOT")) {
changelogType = "markdown"
delegate.changelog = changelog

addGameVersion "1.20.4"
addGameVersion "1.21"
addGameVersion "NeoForge"
addGameVersion "Java 17"
addGameVersion "Java 21"

mainArtifact(jar.archiveFile) {
displayName = "Modern Dynamics v${version}"
Expand All @@ -283,7 +284,7 @@ if (System.getenv("MODRINTH_API_KEY") && !version.endsWith("-SNAPSHOT")) {
delegate.changelog = changelog
versionType = releaseChannel.toUpperCase()
uploadFile = jar.archiveFile
gameVersions = ["1.20.4"]
gameVersions = ["1.21"]
loaders = ["neoforge"]
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pluginManagement {
}
plugins {
id 'net.neoforged.moddev' version '0.1.105'
id 'com.diffplug.spotless' version '5.14.0'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id "com.modrinth.minotaur" version "2.+"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:iron_ingot"
]
"items": "minecraft:iron_ingot"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:ender_pearl"
]
"items": "minecraft:ender_pearl"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:hopper"
]
"items": "minecraft:hopper"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:lapis_lazuli"
]
"items": "minecraft:lapis_lazuli"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:copper_ingot"
]
"items": "minecraft:copper_ingot"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"moderndynamics:item_pipe"
]
"items": "moderndynamics:item_pipe"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:iron_ingot"
]
"items": "minecraft:iron_ingot"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"moderndynamics:fluid_pipe"
]
"items": "moderndynamics:fluid_pipe"
}
]
},
Expand All @@ -17,9 +15,7 @@
"conditions": {
"items": [
{
"items": [
"moderndynamics:item_pipe"
]
"items": "moderndynamics:item_pipe"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
" p "
],
"result": {
"item": "moderndynamics:attractor"
"count": 1,
"id": "moderndynamics:attractor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
" p "
],
"result": {
"item": "moderndynamics:extractor"
"count": 1,
"id": "moderndynamics:extractor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
" p "
],
"result": {
"item": "moderndynamics:filter"
"count": 1,
"id": "moderndynamics:filter"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
],
"result": {
"count": 8,
"item": "moderndynamics:fluid_pipe"
"id": "moderndynamics:fluid_pipe"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
],
"result": {
"count": 4,
"item": "moderndynamics:inhibitor"
"id": "moderndynamics:inhibitor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
],
"result": {
"count": 8,
"item": "moderndynamics:item_pipe"
"id": "moderndynamics:item_pipe"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
],
"result": {
"count": 4,
"item": "moderndynamics:machine_extender"
"id": "moderndynamics:machine_extender"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"il "
],
"result": {
"item": "moderndynamics:wrench"
"count": 1,
"id": "moderndynamics:wrench"
}
}
25 changes: 13 additions & 12 deletions src/main/java/dev/technici4n/moderndynamics/MdBlockEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.common.base.Preconditions;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -48,42 +49,42 @@ public void sync() {
sync(true);
}

public abstract void toTag(CompoundTag tag);
public abstract void toTag(CompoundTag tag, HolderLookup.Provider registries);

public abstract void fromTag(CompoundTag tag);
public abstract void fromTag(CompoundTag tag, HolderLookup.Provider registries);

public abstract void toClientTag(CompoundTag tag);
public abstract void toClientTag(CompoundTag tag, HolderLookup.Provider registries);

public abstract void fromClientTag(CompoundTag tag);
public abstract void fromClientTag(CompoundTag tag, HolderLookup.Provider registries);

@Override
public final ClientboundBlockEntityDataPacket getUpdatePacket() {
return ClientboundBlockEntityDataPacket.create(this);
}

@Override
public final CompoundTag getUpdateTag() {
CompoundTag nbt = super.getUpdateTag();
toClientTag(nbt);
public final CompoundTag getUpdateTag(HolderLookup.Provider registries) {
CompoundTag nbt = super.getUpdateTag(registries);
toClientTag(nbt, registries);
nbt.putBoolean("#c", shouldClientRemesh); // mark client tag
shouldClientRemesh = false;
return nbt;
}

@Override
protected final void saveAdditional(CompoundTag nbt) {
toTag(nbt);
protected final void saveAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
toTag(nbt, registries);
}

@Override
public final void load(CompoundTag nbt) {
public final void loadAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
if (nbt.contains("#c")) {
fromClientTag(nbt);
fromClientTag(nbt, registries);
if (nbt.getBoolean("#c")) {
remesh();
}
} else {
fromTag(nbt);
fromTag(nbt, registries);
}
}

Expand Down
16 changes: 7 additions & 9 deletions src/main/java/dev/technici4n/moderndynamics/ModernDynamics.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import net.neoforged.neoforge.registries.RegisterEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -50,18 +50,16 @@ public class ModernDynamics {

public ModernDynamics(IEventBus modEvents) {
modEvents.addListener(RegisterEvent.class, this::register);
modEvents.addListener(RegisterPayloadHandlerEvent.class, this::registerPayloadHandler);
modEvents.addListener(RegisterPayloadHandlersEvent.class, this::registerPayloadHandlers);

modEvents.addListener(MdBlockEntities::registerCapabilities);
NeoForge.EVENT_BUS.addListener(ServerStoppedEvent.class, e -> {
NetworkManager.onServerStopped();
SimulatedInsertionTargets.clear();
});
NeoForge.EVENT_BUS.addListener(TickEvent.ServerTickEvent.class, e -> {
if (e.phase == TickEvent.Phase.END) {
TickHelper.onEndTick();
NetworkManager.onEndTick();
}
NeoForge.EVENT_BUS.addListener(ServerTickEvent.Post.class, e -> {
TickHelper.onEndTick();
NetworkManager.onEndTick();
});
NeoForge.EVENT_BUS.addListener(WrenchHelper::handleEvent);
AttachmentUpgradesLoader.setup();
Expand All @@ -88,7 +86,7 @@ private void register(RegisterEvent registerEvent) {
}
}

private void registerPayloadHandler(RegisterPayloadHandlerEvent e) {
private void registerPayloadHandlers(RegisterPayloadHandlersEvent e) {
var registrar = e.registrar(MdId.MOD_ID);
MdPackets.register(registrar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import dev.technici4n.moderndynamics.attachment.attached.AttachedAttachment;
import dev.technici4n.moderndynamics.network.NodeHost;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.Item;

Expand All @@ -31,5 +32,5 @@ public AttachmentItem(RenderedAttachment attachment) {
this.attachment = attachment;
}

public abstract AttachedAttachment createAttached(NodeHost host, CompoundTag configTag);
public abstract AttachedAttachment createAttached(NodeHost host, CompoundTag configTag, HolderLookup.Provider registries);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import dev.technici4n.moderndynamics.attachment.attached.AttachedInhibitor;
import dev.technici4n.moderndynamics.network.NodeHost;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;

public class InhibitorAttachmentItem extends AttachmentItem {
Expand All @@ -28,7 +29,7 @@ public InhibitorAttachmentItem(RenderedAttachment attachment) {
}

@Override
public AttachedInhibitor createAttached(NodeHost host, CompoundTag configTag) {
public AttachedInhibitor createAttached(NodeHost host, CompoundTag configTag, HolderLookup.Provider registries) {
return new AttachedInhibitor(this, configTag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
import java.util.List;
import java.util.Set;
import net.minecraft.ChatFormatting;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

public class IoAttachmentItem extends AttachmentItem {
private final IoAttachmentType type;
Expand All @@ -48,11 +47,11 @@ public IoAttachmentType getType() {
}

@Override
public AttachedAttachment createAttached(NodeHost host, CompoundTag configTag) {
public AttachedAttachment createAttached(NodeHost host, CompoundTag configTag, HolderLookup.Provider registries) {
if (host instanceof ItemHost) {
return new ItemAttachedIo(this, configTag, host.getPipe()::setChanged);
return new ItemAttachedIo(this, configTag, host.getPipe()::setChanged, registries);
} else {
return new FluidAttachedIo(this, configTag, host.getPipe()::setChanged);
return new FluidAttachedIo(this, configTag, host.getPipe()::setChanged, registries);
}
}

Expand Down Expand Up @@ -84,7 +83,7 @@ public Set<Setting> getSupportedSettings() {
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltipComponents, TooltipFlag isAdvanced) {
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag isAdvanced) {
tooltipComponents
.add(Component.translatable("gui.moderndynamics.tooltip.attachment_upgrades").setStyle(Style.EMPTY.withColor(ChatFormatting.GOLD)));
/*
Expand Down
Loading

0 comments on commit d38aa65

Please sign in to comment.