mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Drill, it's container and it's screen (blank atm)
This commit is contained in:
parent
de16d7f351
commit
121c2cbcac
9 changed files with 154 additions and 17 deletions
|
@ -0,0 +1,15 @@
|
||||||
|
package de.ellpeck.actuallyadditions.client;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.client.screens.DrillScreen;
|
||||||
|
import de.ellpeck.actuallyadditions.common.container.ActuallyContainers;
|
||||||
|
import net.minecraft.client.gui.ScreenManager;
|
||||||
|
|
||||||
|
public class ClientSetup {
|
||||||
|
public static void setup() {
|
||||||
|
setupScreens();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setupScreens() {
|
||||||
|
ScreenManager.registerFactory(ActuallyContainers.DRILL_CONTAINER.get(), DrillScreen::new);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package de.ellpeck.actuallyadditions.client.screens;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import de.ellpeck.actuallyadditions.common.container.DrillContainer;
|
||||||
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
|
public class DrillScreen extends ContainerScreen<DrillContainer> {
|
||||||
|
public DrillScreen(DrillContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
||||||
|
super(screenContainer, inv, titleIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
|
this.renderBackground(matrixStack);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
@MethodsReturnNonnullByDefault
|
||||||
|
package de.ellpeck.actuallyadditions.client.screens;
|
||||||
|
|
||||||
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
|
@ -1,7 +1,9 @@
|
||||||
package de.ellpeck.actuallyadditions.common;
|
package de.ellpeck.actuallyadditions.common;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.client.ClientSetup;
|
||||||
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.common.config.Config;
|
import de.ellpeck.actuallyadditions.common.config.Config;
|
||||||
|
import de.ellpeck.actuallyadditions.common.container.ActuallyContainers;
|
||||||
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -38,6 +40,7 @@ public class ActuallyAdditions {
|
||||||
|
|
||||||
ActuallyBlocks.BLOCKS.register(eventBus);
|
ActuallyBlocks.BLOCKS.register(eventBus);
|
||||||
ActuallyItems.ITEMS.register(eventBus);
|
ActuallyItems.ITEMS.register(eventBus);
|
||||||
|
ActuallyContainers.CONTAINERS.register(eventBus);
|
||||||
|
|
||||||
eventBus.addListener(this::setup);
|
eventBus.addListener(this::setup);
|
||||||
eventBus.addListener(this::clientSetup);
|
eventBus.addListener(this::clientSetup);
|
||||||
|
@ -49,6 +52,6 @@ public class ActuallyAdditions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clientSetup(FMLClientSetupEvent event) {
|
private void clientSetup(FMLClientSetupEvent event) {
|
||||||
|
ClientSetup.setup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import static net.minecraftforge.common.ForgeConfigSpec.IntValue;
|
||||||
public class ItemConfig {
|
public class ItemConfig {
|
||||||
public final IntValue teleportStaffCost;
|
public final IntValue teleportStaffCost;
|
||||||
public final IntValue teleportStaffMaxEnergy;
|
public final IntValue teleportStaffMaxEnergy;
|
||||||
|
public final IntValue drillMaxEnergy;
|
||||||
|
|
||||||
public ItemConfig() {
|
public ItemConfig() {
|
||||||
COMMON_BUILDER.comment("Item Config Options").push("items");
|
COMMON_BUILDER.comment("Item Config Options").push("items");
|
||||||
|
@ -20,5 +21,9 @@ public class ItemConfig {
|
||||||
teleportStaffMaxEnergy = COMMON_BUILDER
|
teleportStaffMaxEnergy = COMMON_BUILDER
|
||||||
.comment("The max amount of Crystal Flux stored in the Teleport Staff")
|
.comment("The max amount of Crystal Flux stored in the Teleport Staff")
|
||||||
.defineInRange("Teleport Staff Max Energy", 250000, 0, 1000000);
|
.defineInRange("Teleport Staff Max Energy", 250000, 0, 1000000);
|
||||||
|
|
||||||
|
drillMaxEnergy = COMMON_BUILDER
|
||||||
|
.comment("The max energy amount for the drill")
|
||||||
|
.defineInRange("Drill Max Energy", 250000, 0, 1000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.container;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||||
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
|
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||||
|
import net.minecraftforge.fml.RegistryObject;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
|
public final class ActuallyContainers {
|
||||||
|
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ActuallyAdditions.MOD_ID);
|
||||||
|
|
||||||
|
public static final RegistryObject<ContainerType<DrillContainer>> DRILL_CONTAINER
|
||||||
|
= CONTAINERS.register("drill_container", () -> IForgeContainerType.create(DrillContainer::new));
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.container;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.common.items.useables.DrillItem;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
|
||||||
|
public class DrillContainer extends Container {
|
||||||
|
private PlayerInventory inv;
|
||||||
|
|
||||||
|
public DrillContainer(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
|
this(windowId, inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrillContainer(int windowId, PlayerInventory inv) {
|
||||||
|
super(ActuallyContainers.DRILL_CONTAINER.get(), windowId);
|
||||||
|
this.inv = inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(PlayerEntity playerIn) {
|
||||||
|
// Close if the player is not holding the item
|
||||||
|
return playerIn.getHeldItemMainhand().getItem() instanceof DrillItem;
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,22 +112,22 @@ public final class ActuallyItems {
|
||||||
public static final RegistryObject<Item> QUADRUPLE_BATTERY = ITEMS.register("quadruple_battery", () -> new BatteryItem(() -> 1000000, 30000));
|
public static final RegistryObject<Item> QUADRUPLE_BATTERY = ITEMS.register("quadruple_battery", () -> new BatteryItem(() -> 1000000, 30000));
|
||||||
public static final RegistryObject<Item> QUINTUPLE_BATTERY = ITEMS.register("quintuple_battery", () -> new BatteryItem(() -> 2000000, 100000));
|
public static final RegistryObject<Item> QUINTUPLE_BATTERY = ITEMS.register("quintuple_battery", () -> new BatteryItem(() -> 2000000, 100000));
|
||||||
|
|
||||||
public static final RegistryObject<Item> DRILL_MAIN = ITEMS.register("drill_light_blue", basicItem());
|
public static final RegistryObject<Item> DRILL_MAIN = ITEMS.register("drill_light_blue", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_BLACK = ITEMS.register("drill_black", basicItem());
|
public static final RegistryObject<Item> DRILL_BLACK = ITEMS.register("drill_black", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_BLUE = ITEMS.register("drill_blue", basicItem());
|
public static final RegistryObject<Item> DRILL_BLUE = ITEMS.register("drill_blue", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_BROWN = ITEMS.register("drill_brown", basicItem());
|
public static final RegistryObject<Item> DRILL_BROWN = ITEMS.register("drill_brown", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_CYAN = ITEMS.register("drill_cyan", basicItem());
|
public static final RegistryObject<Item> DRILL_CYAN = ITEMS.register("drill_cyan", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_GRAY = ITEMS.register("drill_gray", basicItem());
|
public static final RegistryObject<Item> DRILL_GRAY = ITEMS.register("drill_gray", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_GREEN = ITEMS.register("drill_green", basicItem());
|
public static final RegistryObject<Item> DRILL_GREEN = ITEMS.register("drill_green", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_LIGHT_GRAY = ITEMS.register("drill_light_gray", basicItem());
|
public static final RegistryObject<Item> DRILL_LIGHT_GRAY = ITEMS.register("drill_light_gray", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_LIME = ITEMS.register("drill_lime", basicItem());
|
public static final RegistryObject<Item> DRILL_LIME = ITEMS.register("drill_lime", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_MAGENTA = ITEMS.register("drill_magenta", basicItem());
|
public static final RegistryObject<Item> DRILL_MAGENTA = ITEMS.register("drill_magenta", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_ORANGE = ITEMS.register("drill_orange", basicItem());
|
public static final RegistryObject<Item> DRILL_ORANGE = ITEMS.register("drill_orange", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_PINK = ITEMS.register("drill_pink", basicItem());
|
public static final RegistryObject<Item> DRILL_PINK = ITEMS.register("drill_pink", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_PURPLE = ITEMS.register("drill_purple", basicItem());
|
public static final RegistryObject<Item> DRILL_PURPLE = ITEMS.register("drill_purple", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_RED = ITEMS.register("drill_red", basicItem());
|
public static final RegistryObject<Item> DRILL_RED = ITEMS.register("drill_red", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_WHITE = ITEMS.register("drill_white", basicItem());
|
public static final RegistryObject<Item> DRILL_WHITE = ITEMS.register("drill_white", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_YELLOW = ITEMS.register("drill_yellow", basicItem());
|
public static final RegistryObject<Item> DRILL_YELLOW = ITEMS.register("drill_yellow", DrillItem::new);
|
||||||
public static final RegistryObject<Item> DRILL_SPEED_AUGMENT_I = ITEMS.register("drill_speed_augment_i", basicItem());
|
public static final RegistryObject<Item> DRILL_SPEED_AUGMENT_I = ITEMS.register("drill_speed_augment_i", basicItem());
|
||||||
public static final RegistryObject<Item> DRILL_SPEED_AUGMENT_II = ITEMS.register("drill_speed_augment_ii", basicItem());
|
public static final RegistryObject<Item> DRILL_SPEED_AUGMENT_II = ITEMS.register("drill_speed_augment_ii", basicItem());
|
||||||
public static final RegistryObject<Item> DRILL_SPEED_AUGMENT_III = ITEMS.register("drill_speed_augment_iii", basicItem());
|
public static final RegistryObject<Item> DRILL_SPEED_AUGMENT_III = ITEMS.register("drill_speed_augment_iii", basicItem());
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.items.useables;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.common.config.Config;
|
||||||
|
import de.ellpeck.actuallyadditions.common.container.DrillContainer;
|
||||||
|
import de.ellpeck.actuallyadditions.common.items.CrystalFluxItem;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.ToolType;
|
||||||
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
|
public class DrillItem extends CrystalFluxItem {
|
||||||
|
public DrillItem() {
|
||||||
|
super(
|
||||||
|
baseProps()
|
||||||
|
.maxDamage(0)
|
||||||
|
.setNoRepair()
|
||||||
|
.addToolType(ToolType.PICKAXE, 4)
|
||||||
|
.addToolType(ToolType.SHOVEL, 4),
|
||||||
|
Config.ITEM_CONFIG.drillMaxEnergy::get,
|
||||||
|
1000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand handIn) {
|
||||||
|
if (player.isSneaking() && !worldIn.isRemote && handIn == Hand.MAIN_HAND) {
|
||||||
|
NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider(
|
||||||
|
(windowId, playerInv, playerEntity) -> new DrillContainer(windowId, playerInv),
|
||||||
|
StringTextComponent.EMPTY
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onItemRightClick(worldIn, player, handIn);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue