Skip to content

Commit

Permalink
Basic Port to 19w06a
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed Feb 12, 2019
1 parent 5936e00 commit 32cc30e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Expand Up @@ -6,11 +6,11 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

archivesBaseName = "RoughlyEnoughItems"
version = "2.2.0.49"
version = "2.2.0.50"

def minecraftVersion = "19w05a"
def yarnVersion = "19w05a.5"
def fabricVersion = "0.1.5.88"
def minecraftVersion = "19w06a"
def yarnVersion = "19w06a.5"
def fabricVersion = "0.2.0.92"
def pluginLoaderVersion = "1.14-1.0.6-8"

minecraft {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
Expand Up @@ -10,9 +10,9 @@
import me.shedaniel.rei.update.UpdateChecker;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.api.loader.Loader;
import net.fabricmc.fabric.events.client.ClientTickEvent;
import net.fabricmc.fabric.networking.CustomPayloadPacketRegistry;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
import net.fabricmc.loader.FabricLoader;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -69,15 +69,15 @@ public static Identifier getPluginIdentifier(IRecipePlugin plugin) {
@Override
public void onInitializeClient() {
// If pluginloader is not installed, base functionality should still remain
if (!Loader.getInstance().isModLoaded("pluginloader")) {
if (!FabricLoader.INSTANCE.getModContainers().stream().map(modContainer -> modContainer.getInfo().getId()).anyMatch(s -> s.equalsIgnoreCase("pluginloader"))) {
RoughlyEnoughItemsCore.LOGGER.warn("REI: Plugin Loader is not loaded! Please consider installing https://minecraft.curseforge.com/projects/pluginloader for REI plugin compatibility!");
registerPlugin(new Identifier("roughlyenoughitems", "default_plugin"), new DefaultPlugin());
}
configHelper = new ConfigHelper();

ClientTickEvent.CLIENT.register(GuiHelper::onTick);
ClientTickCallback.EVENT.register(GuiHelper::onTick);
if (getConfigHelper().checkUpdates())
ClientTickEvent.CLIENT.register(UpdateChecker::onTick);
ClientTickCallback.EVENT.register(UpdateChecker::onTick);

new UpdateChecker().onInitializeClient();
}
Expand All @@ -88,12 +88,12 @@ public void onInitialize() {
}

private void registerFabricPackets() {
CustomPayloadPacketRegistry.SERVER.register(DELETE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
ServerSidePacketRegistry.INSTANCE.register(DELETE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer();
if (!player.inventory.getCursorStack().isEmpty())
player.inventory.setCursorStack(ItemStack.EMPTY);
});
CustomPayloadPacketRegistry.SERVER.register(CREATE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
ServerSidePacketRegistry.INSTANCE.register(CREATE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer();
ItemStack stack = packetByteBuf.readItemStack();
if (player.inventory.insertStack(stack.copy()))
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/me/shedaniel/rei/client/ClientHelper.java
Expand Up @@ -11,6 +11,7 @@
import me.shedaniel.rei.gui.widget.RecipeViewingWidgetScreen;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl;
import net.fabricmc.loader.FabricLoader;
import net.minecraft.client.MinecraftClient;
Expand All @@ -22,7 +23,6 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.packet.CustomPayloadServerPacket;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
Expand Down Expand Up @@ -90,16 +90,13 @@ public static void sendDeletePacket() {
MinecraftClient.getInstance().player.inventory.setCursorStack(ItemStack.EMPTY);
return;
}
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new CustomPayloadServerPacket(RoughlyEnoughItemsCore.DELETE_ITEMS_PACKET, buf));
ClientSidePacketRegistry.INSTANCE.sendToServer(RoughlyEnoughItemsCore.DELETE_ITEMS_PACKET, new PacketByteBuf(Unpooled.buffer()));
}

public static boolean tryCheatingStack(ItemStack cheatedStack) {
if (MinecraftClient.getInstance().isInSingleplayer()) {
try {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeItemStack(cheatedStack.copy());
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new CustomPayloadServerPacket(RoughlyEnoughItemsCore.CREATE_ITEMS_PACKET, buf));
ClientSidePacketRegistry.INSTANCE.sendToServer(RoughlyEnoughItemsCore.CREATE_ITEMS_PACKET, new PacketByteBuf(Unpooled.buffer()).writeItemStack(cheatedStack.copy()));
return true;
} catch (Exception e) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Expand Up @@ -12,7 +12,7 @@
"me.shedaniel.rei.client.ClientHelper"
],
"requires": {
"fabric": "0.1.5.88"
"fabric": "0.2.0.92"
},
"recommended": {
"pluginloader": "1.0.6"
Expand Down
9 changes: 9 additions & 0 deletions version.json
Expand Up @@ -11,6 +11,10 @@
{
"game": "19w05a",
"mod": "2.2.0.49"
},
{
"game": "19w06a",
"mod": "2.2.0.50"
}
],
"changelogs": {
Expand All @@ -24,6 +28,11 @@
"version": "2.2.0.49",
"text": "Fixed Crashing when rendering tooltips",
"level": "normal"
},
{
"version": "2.2.0.50",
"text": "Updated to 19w06a",
"level": "none"
}
]
}
Expand Down

0 comments on commit 32cc30e

Please sign in to comment.