-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Erdragh/develop
Version 1.0
- Loading branch information
Showing
11 changed files
with
198 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/main/java/com/github/erdragh/jet_suit_additions/JetSuitAdditions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/github/erdragh/jet_suit_additions/items/armour/ImprovedJetSuit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
src/main/java/com/github/erdragh/jet_suit_additions/mixin/ItemRegistryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
src/main/java/com/github/erdragh/jet_suit_additions/mixin/JetSuitMixin.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/main/java/com/github/erdragh/jet_suit_additions/networking/C2SPackets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters