Skip to content

Commit

Permalink
Merge pull request #1 from Erdragh/develop
Browse files Browse the repository at this point in the history
Version 1.0
  • Loading branch information
Erdragh authored Mar 2, 2023
2 parents 5683822 + 9ad1ea3 commit ee23633
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 28 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx4G
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.4
loader_version=0.14.17
loader_version=0.14.14
# Mod Properties
mod_version=1.0-SNAPSHOT
mod_version=1.0
maven_group=com.github.erdragh
archives_base_name=jet_suit_additions
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.github.erdragh.jet_suit_additions;

import com.github.erdragh.jet_suit_additions.networking.C2SPackets;
import net.fabricmc.api.ModInitializer;

public class JetSuitAdditions implements ModInitializer {

public static final String MODID = "jet_suit_additions";

@java.lang.Override
@Override
public void onInitialize() {
C2SPackets.register();
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.github.erdragh.jet_suit_additions.client;

import com.github.erdragh.jet_suit_additions.JetSuitAdditions;
import com.github.erdragh.jet_suit_additions.networking.C2SPackets;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;

@Environment(EnvType.CLIENT)
Expand All @@ -24,7 +26,7 @@ public void onInitializeClient() {

ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (jetSuitToggle.wasPressed()) {
client.player.sendMessage(Text.of("FUCK"), false);
ClientPlayNetworking.send(C2SPackets.TOGGLE_ON, PacketByteBufs.create());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.erdragh.jet_suit_additions.items.armour;

import com.github.alexnijjar.ad_astra.items.armour.JetSuit;
import com.github.alexnijjar.ad_astra.registry.ModItems;
import com.github.erdragh.jet_suit_additions.JetSuitAdditions;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;

import java.util.List;

public class ImprovedJetSuit extends JetSuit {
public ImprovedJetSuit(ArmorMaterial material, EquipmentSlot slot, Settings settings) {
super(material, slot, settings);
}

@Override
public void fly(PlayerEntity player, ItemStack stack) {
if (!stack.getOrCreateNbt().getBoolean("toggle_on")) return;
super.fly(player, stack);
}

@Override
public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);
if (stack.isOf(ModItems.JET_SUIT)) {
boolean turnedOn = stack.getOrCreateNbt().getBoolean("toggle_on");
Text text = new TranslatableText(JetSuitAdditions.MODID + ".msg.jet_suit_toggle").append(new TranslatableText(JetSuitAdditions.MODID + ".msg.jet_suit_" + (turnedOn ? "on" : "off")).setStyle(Style.EMPTY.withBold(true).withColor(turnedOn ? Formatting.GREEN : Formatting.RED)));

tooltip.add(text);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.github.erdragh.jet_suit_additions.mixin;

import com.github.alexnijjar.ad_astra.items.armour.JetSuit;
import com.github.alexnijjar.ad_astra.registry.ModArmour;
import com.github.alexnijjar.ad_astra.registry.ModItemGroups;
import com.github.alexnijjar.ad_astra.registry.ModItems;
import com.github.erdragh.jet_suit_additions.items.armour.ImprovedJetSuit;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;

@Mixin(ModItems.class)
public class ItemRegistryMixin {
@Redirect(
slice = @Slice(
from = @At(
value = "CONSTANT",
args = {
"stringValue=jet_suit_helmet"
},
ordinal = 0
)
),
at = @At(
value = "NEW",
target = "Lcom/github/alexnijjar/ad_astra/items/armour/JetSuit;*",
ordinal = 0
),
method = "<clinit>"
)
private static JetSuit jetSuitHelmet(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings) {
return new ImprovedJetSuit(material, slot, settings);
}

@Redirect(
slice = @Slice(
from = @At(
value = "CONSTANT",
args = {
"stringValue=jet_suit"
},
ordinal = 0
)
),
at = @At(
value = "NEW",
target = "Lcom/github/alexnijjar/ad_astra/items/armour/JetSuit;*",
ordinal = 0
),
method = "<clinit>"
)
private static JetSuit jetSuit(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings) {
return new ImprovedJetSuit(material, slot, settings);
}

@Redirect(
slice = @Slice(
from = @At(
value = "CONSTANT",
args = {
"stringValue=jet_suit_pants"
},
ordinal = 0
)
),
at = @At(
value = "NEW",
target = "Lcom/github/alexnijjar/ad_astra/items/armour/JetSuit;*",
ordinal = 0
),
method = "<clinit>"
)
private static JetSuit jetSuitPants(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings) {
return new ImprovedJetSuit(material, slot, settings);
}

@Redirect(
slice = @Slice(
from = @At(
value = "CONSTANT",
args = {
"stringValue=jet_suit_boots"
},
ordinal = 0
)
),
at = @At(
value = "NEW",
target = "Lcom/github/alexnijjar/ad_astra/items/armour/JetSuit;*",
ordinal = 0
),
method = "<clinit>"
)
private static JetSuit jetSuitBoots(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings) {
return new ImprovedJetSuit(material, slot, settings);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.erdragh.jet_suit_additions.networking;

import com.github.erdragh.jet_suit_additions.JetSuitAdditions;
import com.github.erdragh.jet_suit_additions.items.armour.ImprovedJetSuit;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;

public class C2SPackets {

public static final Identifier TOGGLE_ON = new Identifier(JetSuitAdditions.MODID, "toggle_on");

public static void register() {
ServerPlayNetworking.registerGlobalReceiver(TOGGLE_ON, (server, player, handler, buf, responseSender) -> {
var chestStack = player.getInventory().getArmorStack(EquipmentSlot.CHEST.getEntitySlotId());
if (chestStack.getItem() instanceof ImprovedJetSuit) {
chestStack.getOrCreateNbt().putBoolean("toggle_on", !chestStack.getOrCreateNbt().getBoolean("toggle_on"));
Text text = new TranslatableText(JetSuitAdditions.MODID + ".msg.jet_suit_toggle").append(new TranslatableText(JetSuitAdditions.MODID + ".msg.jet_suit_" + (chestStack.getOrCreateNbt().getBoolean("toggle_on") ? "on" : "off")));

player.sendMessage(text, true);
}
});
}

}
8 changes: 8 additions & 0 deletions src/main/resources/assets/jet_suit_additions/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"jet_suit_additions.msg.jet_suit_toggle": "Jet Suit turned ",
"jet_suit_additions.msg.jet_suit_on": "on",
"jet_suit_additions.msg.jet_suit_off": "off",

"jet_suit_additions.key_category": "Jet Suit Additions",
"jet_suit_additions.key.toggle_jet_suit": "Turn the Jet Suit on/off"
}
12 changes: 8 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
"authors": [
"Erdragh"
],
"contact": {},
"contact": {
"sources": "https://github.com/Erdragh/JetSuitAdditions",
"issues": "https://github.com/Erdragh/JetSuitAdditions/issues"
},
"license": "MIT",
"icon": "assets/jet_suit_additions/icon.png",
"icon": "icon.png",
"environment": "*",
"entrypoints": {
"client": [
Expand All @@ -23,8 +26,9 @@
"jet_suit_additions.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.17",
"fabricloader": ">=0.14.14",
"fabric": "*",
"minecraft": "1.18.2"
"minecraft": "1.18.2",
"ad_astra": "1.0.6"
}
}
Binary file added src/main/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/resources/jet_suit_additions.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"package": "com.github.erdragh.jet_suit_additions.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"JetSuitMixin"
"ItemRegistryMixin"
],
"client": [
],
Expand Down

0 comments on commit ee23633

Please sign in to comment.