移除特殊等级,规范命名合成表

This commit is contained in:
Atsuihsio 2024-08-03 15:23:01 +08:00
parent c5eacd363c
commit 86ffa2d843
67 changed files with 18 additions and 3325 deletions

View file

@ -97,7 +97,6 @@ public class ModUtils {
addNetworkMessage(FireMessage.class, FireMessage::buffer, FireMessage::new, FireMessage::handler); addNetworkMessage(FireMessage.class, FireMessage::buffer, FireMessage::new, FireMessage::handler);
addNetworkMessage(VehicleFireMessage.class, VehicleFireMessage::buffer, VehicleFireMessage::new, VehicleFireMessage::handler); addNetworkMessage(VehicleFireMessage.class, VehicleFireMessage::buffer, VehicleFireMessage::new, VehicleFireMessage::handler);
addNetworkMessage(FireModeMessage.class, FireModeMessage::buffer, FireModeMessage::new, FireModeMessage::handler); addNetworkMessage(FireModeMessage.class, FireModeMessage::buffer, FireModeMessage::new, FireModeMessage::handler);
addNetworkMessage(GunRecycleGuiButtonMessage.class, GunRecycleGuiButtonMessage::buffer, GunRecycleGuiButtonMessage::new, GunRecycleGuiButtonMessage::handler);
addNetworkMessage(ReloadMessage.class, ReloadMessage::encode, ReloadMessage::decode, ReloadMessage::handler); addNetworkMessage(ReloadMessage.class, ReloadMessage::encode, ReloadMessage::decode, ReloadMessage::handler);
addNetworkMessage(PlayerGunKillMessage.class, PlayerGunKillMessage::encode, PlayerGunKillMessage::decode, PlayerGunKillMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); addNetworkMessage(PlayerGunKillMessage.class, PlayerGunKillMessage::encode, PlayerGunKillMessage::decode, PlayerGunKillMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
addNetworkMessage(ClientIndicatorMessage.class, ClientIndicatorMessage::encode, ClientIndicatorMessage::decode, ClientIndicatorMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); addNetworkMessage(ClientIndicatorMessage.class, ClientIndicatorMessage::encode, ClientIndicatorMessage::decode, ClientIndicatorMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));

View file

@ -1,46 +0,0 @@
package net.mcreator.superbwarfare.block;
import io.netty.buffer.Unpooled;
import net.mcreator.superbwarfare.world.inventory.GunRecycleGuiMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.network.NetworkHooks;
public class GunRecycleBlock extends Block {
public GunRecycleBlock() {
super(BlockBehaviour.Properties.of().sound(SoundType.METAL).strength(1f, 10f));
}
@Override
public InteractionResult use(BlockState blockstate, Level world, BlockPos pos, Player entity, InteractionHand hand, BlockHitResult hit) {
super.use(blockstate, world, pos, entity, hand, hit);
if (entity instanceof ServerPlayer player) {
NetworkHooks.openScreen(player, new MenuProvider() {
@Override
public Component getDisplayName() {
return Component.literal("Gun Recycle");
}
@Override
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
return new GunRecycleGuiMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(pos));
}
}, pos);
}
return InteractionResult.SUCCESS;
}
}

View file

@ -1,89 +0,0 @@
package net.mcreator.superbwarfare.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.network.message.GunRecycleGuiButtonMessage;
import net.mcreator.superbwarfare.world.inventory.GunRecycleGuiMenu;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import java.util.HashMap;
public class GunRecycleGuiScreen extends AbstractContainerScreen<GunRecycleGuiMenu> {
private final static HashMap<String, Object> GUI_STATE = GunRecycleGuiMenu.GUI_STATE;
private final int x, y, z;
private final Player entity;
Button button_dismantle;
public GunRecycleGuiScreen(GunRecycleGuiMenu container, Inventory inventory, Component text) {
super(container, inventory, text);
this.x = container.x;
this.y = container.y;
this.z = container.z;
this.entity = container.entity;
this.imageWidth = 176;
this.imageHeight = 166;
}
private static final ResourceLocation texture = new ResourceLocation("superbwarfare:textures/screens/gun_recycle_gui.png");
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(guiGraphics);
super.render(guiGraphics, mouseX, mouseY, partialTicks);
this.renderTooltip(guiGraphics, mouseX, mouseY);
if (mouseX > leftPos + 58 && mouseX < leftPos + 116 && mouseY > topPos + 54 && mouseY < topPos + 78)
guiGraphics.renderTooltip(font, Component.translatable("gui.superbwarfare.gun_recycle_gui.tooltip_if_guns_level_10you_will_get"), mouseX, mouseY);
}
@Override
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int gx, int gy) {
RenderSystem.setShaderColor(1, 1, 1, 1);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
guiGraphics.blit(texture, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight, this.imageWidth, this.imageHeight);
RenderSystem.disableBlend();
}
@Override
public boolean keyPressed(int key, int b, int c) {
if (key == 256) {
if (this.minecraft != null && this.minecraft.player != null) {
this.minecraft.player.closeContainer();
}
return true;
}
return super.keyPressed(key, b, c);
}
@Override
public void containerTick() {
super.containerTick();
}
@Override
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
guiGraphics.drawString(this.font, Component.translatable("gui.superbwarfare.gun_recycle_gui.label_gun_recycle"), 6, 6, -12829636, false);
}
@Override
public void onClose() {
super.onClose();
}
@Override
public void init() {
super.init();
button_dismantle = Button.builder(Component.translatable("gui.superbwarfare.gun_recycle_gui.button_dismantle"), e -> {
ModUtils.PACKET_HANDLER.sendToServer(new GunRecycleGuiButtonMessage(0, x, y, z));
GunRecycleGuiButtonMessage.handleButtonAction(entity, 0, x, y, z);
}).bounds(this.leftPos + 62, this.topPos + 56, 52, 20).build();
GUI_STATE.put("button:button_dismantle", button_dismantle);
this.addRenderableWidget(button_dismantle);
}
}

View file

@ -17,5 +17,4 @@ public class ModBlocks {
public static final RegistryObject<Block> DEEPSLATE_GALENA_ORE = REGISTRY.register("deepslate_galena_ore", DeepslateGalenaOreBlock::new); public static final RegistryObject<Block> DEEPSLATE_GALENA_ORE = REGISTRY.register("deepslate_galena_ore", DeepslateGalenaOreBlock::new);
public static final RegistryObject<Block> SCHEELITE_ORE = REGISTRY.register("scheelite_ore", ScheeliteOreBlock::new); public static final RegistryObject<Block> SCHEELITE_ORE = REGISTRY.register("scheelite_ore", ScheeliteOreBlock::new);
public static final RegistryObject<Block> DEEPSLATE_SCHEELITE_ORE = REGISTRY.register("deepslate_scheelite_ore", DeepslateScheeliteOreBlock::new); public static final RegistryObject<Block> DEEPSLATE_SCHEELITE_ORE = REGISTRY.register("deepslate_scheelite_ore", DeepslateScheeliteOreBlock::new);
public static final RegistryObject<Block> GUN_RECYCLE = REGISTRY.register("gun_recycle", GunRecycleBlock::new);
} }

View file

@ -101,13 +101,11 @@ public class ModItems {
public static final RegistryObject<Item> PRIMER = ITEMS.register("primer", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> PRIMER = ITEMS.register("primer", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> AP_HEAD = ITEMS.register("ap_head", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> AP_HEAD = ITEMS.register("ap_head", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> HE_HEAD = ITEMS.register("he_head", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> HE_HEAD = ITEMS.register("he_head", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> SOUL_STEEL_NUGGET = ITEMS.register("soul_steel_nugget", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> COPPERPLATE = ITEMS.register("copperplate", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> COPPERPLATE = ITEMS.register("copperplate", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> INGOT_STEEL = ITEMS.register("ingot_steel", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> INGOT_STEEL = ITEMS.register("ingot_steel", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> LEAD_INGOT = ITEMS.register("lead_ingot", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> LEAD_INGOT = ITEMS.register("lead_ingot", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> TUNGSTEN_INGOT = ITEMS.register("tungsten_ingot", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> TUNGSTEN_INGOT = ITEMS.register("tungsten_ingot", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> CEMENTED_CARBIDE_INGOT = ITEMS.register("cemented_carbide_ingot", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> CEMENTED_CARBIDE_INGOT = ITEMS.register("cemented_carbide_ingot", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> SOUL_STEEL_INGOT = ITEMS.register("soul_steel_ingot", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> HIGH_ENERGY_EXPLOSIVES = ITEMS.register("high_energy_explosives", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> HIGH_ENERGY_EXPLOSIVES = ITEMS.register("high_energy_explosives", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> GRAIN = ITEMS.register("grain", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> GRAIN = ITEMS.register("grain", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> IRON_POWDER = ITEMS.register("iron_powder", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> IRON_POWDER = ITEMS.register("iron_powder", () -> new Item(new Item.Properties()));
@ -146,7 +144,6 @@ public class ModItems {
public static final RegistryObject<Item> RARE_MATERIAL_PACK = ITEMS.register("rare_material_pack", () -> new MaterialPack(Rarity.RARE)); public static final RegistryObject<Item> RARE_MATERIAL_PACK = ITEMS.register("rare_material_pack", () -> new MaterialPack(Rarity.RARE));
public static final RegistryObject<Item> EPIC_MATERIAL_PACK = ITEMS.register("epic_material_pack", () -> new MaterialPack(Rarity.EPIC)); public static final RegistryObject<Item> EPIC_MATERIAL_PACK = ITEMS.register("epic_material_pack", () -> new MaterialPack(Rarity.EPIC));
public static final RegistryObject<Item> LEGENDARY_MATERIAL_PACK = ITEMS.register("legendary_material_pack", () -> new MaterialPack(RarityTool.LEGENDARY)); public static final RegistryObject<Item> LEGENDARY_MATERIAL_PACK = ITEMS.register("legendary_material_pack", () -> new MaterialPack(RarityTool.LEGENDARY));
public static final RegistryObject<Item> SPECIAL_MATERIAL_PACK = ITEMS.register("special_material_pack", () -> new MaterialPack(RarityTool.SPECIAL));
public static final RegistryObject<Item> TRACHELIUM_BLUEPRINT = ITEMS.register("trachelium_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY)); public static final RegistryObject<Item> TRACHELIUM_BLUEPRINT = ITEMS.register("trachelium_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY));
public static final RegistryObject<Item> GLOCK_17_BLUEPRINT = ITEMS.register("glock_17_blueprint", () -> new BlueprintItem(Rarity.COMMON)); public static final RegistryObject<Item> GLOCK_17_BLUEPRINT = ITEMS.register("glock_17_blueprint", () -> new BlueprintItem(Rarity.COMMON));
@ -154,15 +151,15 @@ public class ModItems {
public static final RegistryObject<Item> HUNTING_RIFLE_BLUEPRINT = ITEMS.register("hunting_rifle_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> HUNTING_RIFLE_BLUEPRINT = ITEMS.register("hunting_rifle_blueprint", () -> new BlueprintItem(Rarity.EPIC));
public static final RegistryObject<Item> M_79_BLUEPRINT = ITEMS.register("m_79_blueprint", () -> new BlueprintItem(Rarity.RARE)); public static final RegistryObject<Item> M_79_BLUEPRINT = ITEMS.register("m_79_blueprint", () -> new BlueprintItem(Rarity.RARE));
public static final RegistryObject<Item> RPG_BLUEPRINT = ITEMS.register("rpg_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> RPG_BLUEPRINT = ITEMS.register("rpg_blueprint", () -> new BlueprintItem(Rarity.EPIC));
public static final RegistryObject<Item> BOCEK_BLUEPRINT = ITEMS.register("bocek_blueprint", () -> new BlueprintItem(RarityTool.SPECIAL)); public static final RegistryObject<Item> BOCEK_BLUEPRINT = ITEMS.register("bocek_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY));
public static final RegistryObject<Item> M_4_BLUEPRINT = ITEMS.register("m_4_blueprint", () -> new BlueprintItem(Rarity.RARE)); public static final RegistryObject<Item> M_4_BLUEPRINT = ITEMS.register("m_4_blueprint", () -> new BlueprintItem(Rarity.RARE));
public static final RegistryObject<Item> AA_12_BLUEPRINT = ITEMS.register("aa_12_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY)); public static final RegistryObject<Item> AA_12_BLUEPRINT = ITEMS.register("aa_12_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY));
public static final RegistryObject<Item> HK_416_BLUEPRINT = ITEMS.register("hk_416_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> HK_416_BLUEPRINT = ITEMS.register("hk_416_blueprint", () -> new BlueprintItem(Rarity.EPIC));
public static final RegistryObject<Item> RPK_BLUEPRINT = ITEMS.register("rpk_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> RPK_BLUEPRINT = ITEMS.register("rpk_blueprint", () -> new BlueprintItem(Rarity.EPIC));
public static final RegistryObject<Item> SKS_BLUEPRINT = ITEMS.register("sks_blueprint", () -> new BlueprintItem(Rarity.RARE)); public static final RegistryObject<Item> SKS_BLUEPRINT = ITEMS.register("sks_blueprint", () -> new BlueprintItem(Rarity.RARE));
public static final RegistryObject<Item> NTW_20_BLUEPRINT = ITEMS.register("ntw_20_blueprint", () -> new BlueprintItem(RarityTool.SPECIAL)); public static final RegistryObject<Item> NTW_20_BLUEPRINT = ITEMS.register("ntw_20_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY));
public static final RegistryObject<Item> VECTOR_BLUEPRINT = ITEMS.register("vector_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> VECTOR_BLUEPRINT = ITEMS.register("vector_blueprint", () -> new BlueprintItem(Rarity.EPIC));
public static final RegistryObject<Item> MINIGUN_BLUEPRINT = ITEMS.register("minigun_blueprint", () -> new BlueprintItem(RarityTool.SPECIAL)); public static final RegistryObject<Item> MINIGUN_BLUEPRINT = ITEMS.register("minigun_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY));
public static final RegistryObject<Item> MK_14_BLUEPRINT = ITEMS.register("mk_14_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> MK_14_BLUEPRINT = ITEMS.register("mk_14_blueprint", () -> new BlueprintItem(Rarity.EPIC));
public static final RegistryObject<Item> SENTINEL_BLUEPRINT = ITEMS.register("sentinel_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY)); public static final RegistryObject<Item> SENTINEL_BLUEPRINT = ITEMS.register("sentinel_blueprint", () -> new BlueprintItem(RarityTool.LEGENDARY));
public static final RegistryObject<Item> M_60_BLUEPRINT = ITEMS.register("m_60_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> M_60_BLUEPRINT = ITEMS.register("m_60_blueprint", () -> new BlueprintItem(Rarity.EPIC));
@ -174,7 +171,6 @@ public class ModItems {
public static final RegistryObject<Item> DEVOTION_BLUEPRINT = ITEMS.register("devotion_blueprint", () -> new BlueprintItem(Rarity.EPIC)); public static final RegistryObject<Item> DEVOTION_BLUEPRINT = ITEMS.register("devotion_blueprint", () -> new BlueprintItem(Rarity.EPIC));
public static final RegistryObject<Item> TASER_BLUEPRINT = ITEMS.register("taser_blueprint", () -> new BlueprintItem(Rarity.COMMON)); public static final RegistryObject<Item> TASER_BLUEPRINT = ITEMS.register("taser_blueprint", () -> new BlueprintItem(Rarity.COMMON));
public static final RegistryObject<Item> GUN_RECYCLE = block(ModBlocks.GUN_RECYCLE);
private static RegistryObject<Item> block(RegistryObject<Block> block) { private static RegistryObject<Item> block(RegistryObject<Block> block) {
return ITEMS.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties())); return ITEMS.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));

View file

@ -1,15 +1,12 @@
package net.mcreator.superbwarfare.init; package net.mcreator.superbwarfare.init;
import net.mcreator.superbwarfare.ModUtils; import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.world.inventory.GunRecycleGuiMenu;
import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModMenus { public class ModMenus {
public static final DeferredRegister<MenuType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.MENU_TYPES, ModUtils.MODID); public static final DeferredRegister<MenuType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.MENU_TYPES, ModUtils.MODID);
public static final RegistryObject<MenuType<GunRecycleGuiMenu>> GUN_RECYCLE_GUI = REGISTRY.register("gun_recycle_gui", () -> IForgeMenuType.create(GunRecycleGuiMenu::new));
} }

View file

@ -1,7 +1,5 @@
package net.mcreator.superbwarfare.init; package net.mcreator.superbwarfare.init;
import net.mcreator.superbwarfare.client.gui.GunRecycleGuiScreen;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
@ -12,7 +10,7 @@ public class ModScreens {
@SubscribeEvent @SubscribeEvent
public static void clientLoad(FMLClientSetupEvent event) { public static void clientLoad(FMLClientSetupEvent event) {
event.enqueueWork(() -> { event.enqueueWork(() -> {
MenuScreens.register(ModMenus.GUN_RECYCLE_GUI.get(), GunRecycleGuiScreen::new);
}); });
} }
} }

View file

@ -48,7 +48,7 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
public static ItemDisplayContext transformType; public static ItemDisplayContext transformType;
public BocekItem() { public BocekItem() {
super(new Item.Properties().stacksTo(1).rarity(RarityTool.SPECIAL)); super(new Item.Properties().stacksTo(1).rarity(RarityTool.LEGENDARY));
} }
@Override @Override

View file

@ -53,7 +53,7 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
public static ItemDisplayContext transformType; public static ItemDisplayContext transformType;
public Minigun() { public Minigun() {
super(new Item.Properties().stacksTo(1).rarity(RarityTool.SPECIAL)); super(new Item.Properties().stacksTo(1).rarity(RarityTool.LEGENDARY));
} }
@Override @Override

View file

@ -52,7 +52,7 @@ public class Ntw20 extends GunItem implements GeoItem, AnimatedItem {
public static ItemDisplayContext transformType; public static ItemDisplayContext transformType;
public Ntw20() { public Ntw20() {
super(new Item.Properties().stacksTo(1).rarity(RarityTool.SPECIAL)); super(new Item.Properties().stacksTo(1).rarity(RarityTool.LEGENDARY));
} }
@Override @Override

View file

@ -1,102 +0,0 @@
package net.mcreator.superbwarfare.network.message;
import net.mcreator.superbwarfare.init.ModItems;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.world.inventory.GunRecycleGuiMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class GunRecycleGuiButtonMessage {
private final int buttonID, x, y, z;
public GunRecycleGuiButtonMessage(FriendlyByteBuf buffer) {
this.buttonID = buffer.readInt();
this.x = buffer.readInt();
this.y = buffer.readInt();
this.z = buffer.readInt();
}
public GunRecycleGuiButtonMessage(int buttonID, int x, int y, int z) {
this.buttonID = buttonID;
this.x = x;
this.y = y;
this.z = z;
}
public static void buffer(GunRecycleGuiButtonMessage message, FriendlyByteBuf buffer) {
buffer.writeInt(message.buttonID);
buffer.writeInt(message.x);
buffer.writeInt(message.y);
buffer.writeInt(message.z);
}
public static void handler(GunRecycleGuiButtonMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
NetworkEvent.Context context = contextSupplier.get();
context.enqueueWork(() -> {
Player player = context.getSender();
int buttonID = message.buttonID;
int x = message.x;
int y = message.y;
int z = message.z;
if (player == null) return;
handleButtonAction(player, buttonID, x, y, z);
});
context.setPacketHandled(true);
}
public static void handleButtonAction(Player player, int buttonID, int x, int y, int z) {
// security measure to prevent arbitrary chunk generation
if (!player.level().isLoaded(new BlockPos(x, y, z))) return;
if (buttonID == 0) {
dismantleGun(player);
}
}
private static void dismantleGun(Player player) {
var menu = ((GunRecycleGuiMenu) player.containerMenu).get();
var slot0 = menu.get(0);
var gun = slot0.getItem();
if (gun.is(ModTags.Items.GUN)) {
// 普通稀有度
var material = switch (gun.getRarity()) {
case COMMON -> ModItems.COMMON_MATERIAL_PACK.get();
case RARE -> ModItems.RARE_MATERIAL_PACK.get();
case EPIC -> ModItems.EPIC_MATERIAL_PACK.get();
default -> null;
};
if (material != null) ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(material));
// 特殊稀有度
if (gun.is(ModTags.Items.LEGENDARY_GUN)) {
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.LEGENDARY_MATERIAL_PACK.get()));
}
if (gun.is(ModTags.Items.SPECIAL_GUN)) {
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.SPECIAL_MATERIAL_PACK.get()));
}
// 高等级额外奖励
int level = gun.getOrCreateTag().getInt("level");
if (level >= 10) {
var soulSteelNuggetCount = 0;
if (Math.random() < 0.005 * level) soulSteelNuggetCount += 3;
if (Math.random() < 0.01 * level) soulSteelNuggetCount += 2;
if (Math.random() < 0.03 * level) soulSteelNuggetCount++;
if (Math.random() < 0.06 * level) soulSteelNuggetCount++;
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.SOUL_STEEL_NUGGET.get(), soulSteelNuggetCount));
}
slot0.set(ItemStack.EMPTY);
player.containerMenu.broadcastChanges();
}
}
}

View file

@ -1,238 +0,0 @@
package net.mcreator.superbwarfare.world.inventory;
import net.mcreator.superbwarfare.init.ModMenus;
import net.mcreator.superbwarfare.init.ModTags;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.SlotItemHandler;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
public class GunRecycleGuiMenu extends AbstractContainerMenu implements Supplier<Map<Integer, Slot>> {
public final static HashMap<String, Object> GUI_STATE = new HashMap<>();
public final Level world;
public final Player entity;
public int x, y, z;
private ContainerLevelAccess access = ContainerLevelAccess.NULL;
private IItemHandler internal;
private final Map<Integer, Slot> customSlots = new HashMap<>();
private boolean bound = false;
private Supplier<Boolean> boundItemMatcher = null;
private Entity boundEntity = null;
private BlockEntity boundBlockEntity = null;
public GunRecycleGuiMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
super(ModMenus.GUN_RECYCLE_GUI.get(), id);
this.entity = inv.player;
this.world = inv.player.level();
this.internal = new ItemStackHandler(1);
BlockPos pos = null;
if (extraData != null) {
pos = extraData.readBlockPos();
this.x = pos.getX();
this.y = pos.getY();
this.z = pos.getZ();
access = ContainerLevelAccess.create(world, pos);
}
if (pos != null) {
if (extraData.readableBytes() == 1) { // bound to item
byte hand = extraData.readByte();
ItemStack itemstack = hand == 0 ? this.entity.getMainHandItem() : this.entity.getOffhandItem();
this.boundItemMatcher = () -> itemstack == (hand == 0 ? this.entity.getMainHandItem() : this.entity.getOffhandItem());
itemstack.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
this.internal = capability;
this.bound = true;
});
} else if (extraData.readableBytes() > 1) { // bound to entity
extraData.readByte(); // drop padding
boundEntity = world.getEntity(extraData.readVarInt());
if (boundEntity != null)
boundEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
this.internal = capability;
this.bound = true;
});
} else { // might be bound to block
boundBlockEntity = this.world.getBlockEntity(pos);
if (boundBlockEntity != null)
boundBlockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
this.internal = capability;
this.bound = true;
});
}
}
this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 79, 27) {
@Override
public boolean mayPlace(ItemStack stack) {
return stack.is(ModTags.Items.GUN);
}
}));
for (int si = 0; si < 3; ++si) {
for (int sj = 0; sj < 9; ++sj) {
this.addSlot(new Slot(inv, sj + (si + 1) * 9, 8 + sj * 18, 84 + si * 18));
}
}
for (int si = 0; si < 9; ++si) {
this.addSlot(new Slot(inv, si, 8 + si * 18, 142));
}
}
@Override
public boolean stillValid(Player player) {
if (this.bound) {
if (this.boundItemMatcher != null)
return this.boundItemMatcher.get();
else if (this.boundBlockEntity != null)
return AbstractContainerMenu.stillValid(this.access, player, this.boundBlockEntity.getBlockState().getBlock());
else if (this.boundEntity != null)
return this.boundEntity.isAlive();
}
return true;
}
@Override
public ItemStack quickMoveStack(Player playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.slots.get(index);
if (slot.hasItem()) {
ItemStack itemStack = slot.getItem();
itemstack = itemStack.copy();
if (index < 1) {
if (!this.moveItemStackTo(itemStack, 1, this.slots.size(), true))
return ItemStack.EMPTY;
slot.onQuickCraft(itemStack, itemstack);
} else if (!this.moveItemStackTo(itemStack, 0, 1, false)) {
if (index < 1 + 27) {
if (!this.moveItemStackTo(itemStack, 1 + 27, this.slots.size(), true))
return ItemStack.EMPTY;
} else {
if (!this.moveItemStackTo(itemStack, 1, 1 + 27, false))
return ItemStack.EMPTY;
}
return ItemStack.EMPTY;
}
if (itemStack.getCount() == 0)
slot.set(ItemStack.EMPTY);
else
slot.setChanged();
if (itemStack.getCount() == itemstack.getCount())
return ItemStack.EMPTY;
slot.onTake(playerIn, itemStack);
}
return itemstack;
}
@Override
protected boolean moveItemStackTo(ItemStack p_38904_, int p_38905_, int p_38906_, boolean p_38907_) {
boolean flag = false;
int i = p_38905_;
if (p_38907_) {
i = p_38906_ - 1;
}
if (p_38904_.isStackable()) {
while (!p_38904_.isEmpty()) {
if (p_38907_) {
if (i < p_38905_) {
break;
}
} else if (i >= p_38906_) {
break;
}
Slot slot = this.slots.get(i);
ItemStack itemstack = slot.getItem();
if (slot.mayPlace(itemstack) && !itemstack.isEmpty() && ItemStack.isSameItemSameTags(p_38904_, itemstack)) {
int j = itemstack.getCount() + p_38904_.getCount();
int maxSize = Math.min(slot.getMaxStackSize(), p_38904_.getMaxStackSize());
if (j <= maxSize) {
p_38904_.setCount(0);
itemstack.setCount(j);
slot.set(itemstack);
flag = true;
} else if (itemstack.getCount() < maxSize) {
p_38904_.shrink(maxSize - itemstack.getCount());
itemstack.setCount(maxSize);
slot.set(itemstack);
flag = true;
}
}
if (p_38907_) {
--i;
} else {
++i;
}
}
}
if (!p_38904_.isEmpty()) {
if (p_38907_) {
i = p_38906_ - 1;
} else {
i = p_38905_;
}
while (true) {
if (p_38907_) {
if (i < p_38905_) {
break;
}
} else if (i >= p_38906_) {
break;
}
Slot slot1 = this.slots.get(i);
ItemStack itemstack1 = slot1.getItem();
if (itemstack1.isEmpty() && slot1.mayPlace(p_38904_)) {
if (p_38904_.getCount() > slot1.getMaxStackSize()) {
slot1.setByPlayer(p_38904_.split(slot1.getMaxStackSize()));
} else {
slot1.setByPlayer(p_38904_.split(p_38904_.getCount()));
}
slot1.setChanged();
flag = true;
break;
}
if (p_38907_) {
--i;
} else {
++i;
}
}
}
return flag;
}
@Override
public void removed(Player playerIn) {
super.removed(playerIn);
if (!bound && playerIn instanceof ServerPlayer serverPlayer) {
if (!serverPlayer.isAlive() || serverPlayer.hasDisconnected()) {
for (int j = 0; j < internal.getSlots(); ++j) {
playerIn.drop(internal.extractItem(j, internal.getStackInSlot(j).getCount(), false), false);
}
} else {
for (int i = 0; i < internal.getSlots(); ++i) {
playerIn.getInventory().placeItemBackInInventory(internal.extractItem(i, internal.getStackInSlot(i).getCount(), false));
}
}
}
}
public Map<Integer, Slot> get() {
return customSlots;
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "superbwarfare:item/soul_steel_ingot"
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "superbwarfare:item/soul_steel_nugget"
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "superbwarfare:item/special_material_pack"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 B

View file

@ -189,7 +189,7 @@
{ {
"type": "minecraft:item", "type": "minecraft:item",
"name": "superbwarfare:ntw_20_blueprint", "name": "superbwarfare:ntw_20_blueprint",
"weight": 30, "weight": 50,
"functions": [ "functions": [
{ {
"function": "set_count", "function": "set_count",
@ -203,7 +203,7 @@
{ {
"type": "minecraft:item", "type": "minecraft:item",
"name": "superbwarfare:bocek_blueprint", "name": "superbwarfare:bocek_blueprint",
"weight": 30, "weight": 50,
"functions": [ "functions": [
{ {
"function": "set_count", "function": "set_count",
@ -217,7 +217,7 @@
{ {
"type": "minecraft:item", "type": "minecraft:item",
"name": "superbwarfare:minigun_blueprint", "name": "superbwarfare:minigun_blueprint",
"weight": 30, "weight": 50,
"functions": [ "functions": [
{ {
"function": "set_count", "function": "set_count",

View file

@ -4,7 +4,7 @@
"item": "superbwarfare:bocek_blueprint" "item": "superbwarfare:bocek_blueprint"
}, },
"base": { "base": {
"item": "superbwarfare:special_material_pack" "item": "superbwarfare:legendary_material_pack"
}, },
"addition": { "addition": {
"item": "minecraft:bow" "item": "minecraft:bow"

View file

@ -1,21 +0,0 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"pattern": [
"aa",
"bb",
"bb"
],
"key": {
"a": {
"item": "superbwarfare:ingot_steel"
},
"b": {
"tag": "minecraft:planks"
}
},
"result": {
"item": "superbwarfare:gun_recycle",
"count": 1
}
}

View file

@ -4,7 +4,7 @@
"item": "superbwarfare:minigun_blueprint" "item": "superbwarfare:minigun_blueprint"
}, },
"base": { "base": {
"item": "superbwarfare:special_material_pack" "item": "superbwarfare:legendary_material_pack"
}, },
"addition": { "addition": {
"item": "minecraft:netherite_ingot" "item": "minecraft:netherite_ingot"

View file

@ -4,7 +4,7 @@
"item": "superbwarfare:ntw_20_blueprint" "item": "superbwarfare:ntw_20_blueprint"
}, },
"base": { "base": {
"item": "superbwarfare:special_material_pack" "item": "superbwarfare:legendary_material_pack"
}, },
"addition": { "addition": {
"item": "minecraft:spyglass" "item": "minecraft:spyglass"

View file

@ -1,37 +0,0 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
},
{
"item": "superbwarfare:soul_steel_nugget"
}
],
"result": {
"item": "superbwarfare:soul_steel_ingot",
"count": 1
}
}

View file

@ -1,13 +0,0 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "superbwarfare:soul_steel_ingot"
}
],
"result": {
"item": "superbwarfare:soul_steel_nugget",
"count": 9
}
}

View file

@ -1,15 +0,0 @@
{
"type": "minecraft:smithing_transform",
"template": {
"item": "superbwarfare:legendary_material_pack"
},
"base": {
"item": "superbwarfare:soul_steel_ingot"
},
"addition": {
"item": "minecraft:nether_star"
},
"result": {
"item": "superbwarfare:special_material_pack"
}
}

View file

@ -3,6 +3,9 @@
"values": [ "values": [
"superbwarfare:trachelium", "superbwarfare:trachelium",
"superbwarfare:aa_12", "superbwarfare:aa_12",
"superbwarfare:sentinel" "superbwarfare:sentinel",
"superbwarfare:bocek",
"superbwarfare:ntw_20",
"superbwarfare:minigun"
] ]
} }

View file

@ -1,8 +0,0 @@
{
"replace": false,
"values": [
"superbwarfare:bocek",
"superbwarfare:ntw_20",
"superbwarfare:minigun"
]
}