This commit is contained in:
benpospo@gmail.com 2023-07-02 12:27:36 +02:00 committed by drcrazy
parent 770b7fced9
commit 6a09eb859c
9 changed files with 131 additions and 9 deletions

View file

@ -57,6 +57,7 @@ import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
import reborncore.client.ClientJumpEvent;
import reborncore.client.ClientNetworkManager;
import reborncore.client.gui.GuiBase;
import reborncore.client.multiblock.MultiblockRenderer;
import reborncore.common.powerSystem.RcEnergyItem;
@ -83,6 +84,7 @@ import techreborn.items.FrequencyTransmitterItem;
import techreborn.items.armor.BatpackItem;
import techreborn.items.tool.ChainsawItem;
import techreborn.items.tool.industrial.NanosaberItem;
import techreborn.packets.ServerboundPackets;
import java.util.Arrays;
import java.util.Collection;
@ -114,6 +116,7 @@ public class TechRebornClient implements ClientModInitializer {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (nanoSuitFlight.wasPressed()) {
client.player.sendMessage(Text.literal("Key 1 was pressed!"), false);
ClientNetworkManager.sendToServer(ServerboundPackets.createPacketNanoSuitFlight());
}
});
});

View file

@ -304,9 +304,12 @@ public class TechRebornConfig {
@Config(config = "items", category = "power", key = "nanoSuitCapacity", comment = "Nano Suit Energy Capacity")
public static long nanoSuitCapacity = 1_000_000;
@Config(config = "items", category = "power", key = "nanoSuitNightVisionCost", comment = "Nano Suit Breathing Cost")
@Config(config = "items", category = "power", key = "nanoSuitNightVisionCost", comment = "Nano Suit Night Vision Cost")
public static long nanoSuitNightVisionCost = 2;
@Config(config = "items", category = "power", key = "nanoSuitFlightCost", comment = "Nano Suit Flight Cost")
public static long nanoSuitFlightCost = 2;
@Config(config = "items", category = "upgrades", key = "overclocker_speed", comment = "Overclocker behavior speed multiplier")
public static double overclockerSpeed = 0.25;

View file

@ -28,7 +28,6 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.mojang.authlib.minecraft.client.MinecraftClient;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
@ -38,13 +37,15 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.text.Text;
import net.minecraft.world.World;
import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.common.powerSystem.RcEnergyTier;
import techreborn.config.TechRebornConfig;
public class NanoSuitItem extends TREnergyArmourItem implements ArmorBlockEntityTicker {
public NanoSuitItem(ArmorMaterial material, Type slot) {
super(material, slot, TechRebornConfig.nanoSuitCapacity, RcEnergyTier.HIGH);
}
@ -84,9 +85,27 @@ public class NanoSuitItem extends TREnergyArmourItem implements ArmorBlockEntity
playerEntity.removeStatusEffect(StatusEffects.NIGHT_VISION);
}
}
case CHEST, FEET, LEGS -> {
// Future functionality
case FEET -> {
if (tryUseEnergy(stack, TechRebornConfig.nanoSuitFlightCost)) {
playerEntity.setNoGravity(true);
playerEntity.updatePosition(playerEntity.getX(), playerEntity.getY() + 0.1, playerEntity.getZ());
world.addParticle(ParticleTypes.SOUL_FIRE_FLAME, playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), 0.0, -1.0, 0.0);
} else {
playerEntity.setNoGravity(false);
playerEntity.sendMessage(Text.literal("uwu"));
}
}
}
}
public void boostPlayer(ItemStack stack, PlayerEntity playerEntity) {
World world = playerEntity.getWorld();
if (tryUseEnergy(stack, TechRebornConfig.nanoSuitFlightCost)) {
playerEntity.setNoGravity(true);
playerEntity.updatePosition(playerEntity.getX(), playerEntity.getY() + 0.3, playerEntity.getZ());
world.addParticle(ParticleTypes.SOUL_FIRE_FLAME, playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), 1.0, 1.0, 1.0);
} else {
playerEntity.setNoGravity(false);
}
}
}

View file

@ -25,10 +25,13 @@
package techreborn.packets;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.common.network.IdentifiedPacket;
import reborncore.common.network.NetworkManager;
import techreborn.TechReborn;
@ -44,7 +47,9 @@ import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRArmorMaterials;
import techreborn.init.TRContent;
import techreborn.items.armor.NanoSuitItem;
public class ServerboundPackets {
@ -61,6 +66,7 @@ public class ServerboundPackets {
public static final Identifier JUMP = new Identifier(TechReborn.MOD_ID, "jump");
public static final Identifier PUMP_DEPTH = new Identifier(TechReborn.MOD_ID, "pump_depth");
public static final Identifier PUMP_RANGE = new Identifier(TechReborn.MOD_ID, "pump_range");
public static final Identifier NANO_SUIT_FLIGHT = new Identifier(TechReborn.MOD_ID, "nano_suit_flight");
public static void init() {
NetworkManager.registerServerBoundHandler(AESU, (server, player, handler, buf, responseSender) -> {
@ -226,6 +232,17 @@ public class ServerboundPackets {
});
}));
NetworkManager.registerServerBoundHandler(NANO_SUIT_FLIGHT, ((server, player, handler, buf, responseSender) -> {
NanoSuitItem nanoSuitItem = new NanoSuitItem(TRArmorMaterials.NANO, ArmorItem.Type.BOOTS);
server.execute(() -> {
for (ItemStack stack : player.getArmorItems()) {
if (!stack.isEmpty() && stack.getItem().equals(TRContent.NANO_BOOTS)) {
nanoSuitItem.boostPlayer(stack, player);
}
}
});
}));
}
public static IdentifiedPacket createPacketAesu(int buttonID, boolean shift, boolean ctrl, AdjustableSUBlockEntity blockEntity) {
@ -317,4 +334,8 @@ public class ServerboundPackets {
buf.writeInt(buttonAmount);
});
}
public static IdentifiedPacket createPacketNanoSuitFlight() {
return NetworkManager.createServerBoundPacket(NANO_SUIT_FLIGHT, buf -> {});
}
}

View file

@ -1,4 +0,0 @@
package techreborn.utils;
public class JetpackUtils {
}

View file

@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"E E",
"C C"
],
"key": {
"C": {
"item": "techreborn:carbon_plate"
},
"E": {
"item": "techreborn:energy_crystal"
}
},
"result": {
"item": "techreborn:nano_boots"
}
}

View file

@ -0,0 +1,22 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"C C",
"CEC",
"CAC"
],
"key": {
"C": {
"item": "techreborn:carbon_plate"
},
"A": {
"item": "techreborn:advanced_circuit"
},
"E": {
"item": "techreborn:energy_crystal"
}
},
"result": {
"item": "techreborn:nano_leggings"
}
}

View file

@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CEC",
"C C"
],
"key": {
"C": {
"item": "techreborn:carbon_plate"
},
"E": {
"item": "techreborn:energy_crystal"
}
},
"result": {
"item": "techreborn:nano_helmet"
}
}

View file

@ -0,0 +1,22 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CAC",
"E E",
"C C"
],
"key": {
"C": {
"item": "techreborn:carbon_plate"
},
"A": {
"item": "techreborn:advanced_circuit"
},
"E": {
"item": "techreborn:energy_crystal"
}
},
"result": {
"item": "techreborn:nano_leggings"
}
}