Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the wired charger #172

Merged
merged 11 commits into from
Jul 25, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
### Added
- Added missing tooltips for IO Config button and Neighbour button.
- Better multismelting support for the alloy smelter
- Wired Charger

### Changed
- Grindstone crafting for grains of infinity and powdered coal now uses an in-world craft by right-clicking with flint in the off-hand and the ingredient in the main-hand. Also works with obsidian and crying obsidian (the latter of which has a chance to give a better rate of return on the craft).
Expand Down
34 changes: 34 additions & 0 deletions src/core/java/com/enderio/core/common/menu/SyncedMenu.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
package com.enderio.core.common.menu;

import com.enderio.core.common.blockentity.EnderBlockEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
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.InventoryMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

import static net.minecraft.world.inventory.InventoryMenu.*;
import static net.minecraft.world.inventory.InventoryMenu.EMPTY_ARMOR_SLOT_HELMET;

public abstract class SyncedMenu<T extends EnderBlockEntity> extends AbstractContainerMenu {

@Nullable
Expand All @@ -18,6 +27,9 @@ public abstract class SyncedMenu<T extends EnderBlockEntity> extends AbstractCon

private final List<Slot> playerInventorySlots = new ArrayList<>();
private boolean playerInvVisible = true;

private static final ResourceLocation[] ARMOR_SLOT_TEXTURES = new ResourceLocation[] { EMPTY_ARMOR_SLOT_BOOTS, EMPTY_ARMOR_SLOT_LEGGINGS, EMPTY_ARMOR_SLOT_CHESTPLATE, EMPTY_ARMOR_SLOT_HELMET };
private static final EquipmentSlot[] EQUIPMENT_SLOTS = new EquipmentSlot[] { EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET };
protected SyncedMenu(@Nullable T blockEntity, Inventory inventory, @Nullable MenuType<?> pMenuType, int pContainerId) {
super(pMenuType, pContainerId);
this.blockEntity = blockEntity;
Expand Down Expand Up @@ -48,6 +60,28 @@ public void addInventorySlots(int xPos, int yPos) {
}

}
public void addArmorSlots(int xPos, int Ypos) {
for (int i = 0; i < 4; i++) {
EquipmentSlot slot = EQUIPMENT_SLOTS[i];
this.addSlot(new Slot(inventory, 36 + (3 - i), xPos, Ypos + i * 18) {
@Override
public int getMaxStackSize() {
return 1;
}

@Override
public boolean mayPlace(ItemStack stack) {
return stack.canEquip(slot, inventory.player);
}

@Override
public boolean mayPickup(Player player) {
ItemStack itemstack = this.getItem();
return super.mayPickup(player) && !EnchantmentHelper.hasBindingCurse(itemstack);
}
}.setBackground(InventoryMenu.BLOCK_ATLAS, ARMOR_SLOT_TEXTURES[slot.getIndex()]));
}
}

public boolean getPlayerInvVisible() {
return playerInvVisible;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"variants": {
"facing=east,powered=false": {
"model": "enderio:block/wired_charger",
"y": 90
},
"facing=east,powered=true": {
"model": "enderio:block/wired_charger_on",
"y": 90
},
"facing=north,powered=false": {
"model": "enderio:block/wired_charger"
},
"facing=north,powered=true": {
"model": "enderio:block/wired_charger_on"
},
"facing=south,powered=false": {
"model": "enderio:block/wired_charger",
"y": 180
},
"facing=south,powered=true": {
"model": "enderio:block/wired_charger_on",
"y": 180
},
"facing=west,powered=false": {
"model": "enderio:block/wired_charger",
"y": 270
},
"facing=west,powered=true": {
"model": "enderio:block/wired_charger_on",
"y": 270
}
}
}
1 change: 1 addition & 0 deletions src/generated/resources/assets/enderio/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@
"block.enderio.vibrant_capacitor_bank": "ʞuɐᗺ ɹoʇıɔɐdɐƆ ʇuɐɹqıΛ",
"block.enderio.vibrant_photovoltaic_cell": "ןןǝƆ ɔıɐʇןoʌoʇoɥԀ ʇuɐɹqıΛ",
"block.enderio.void_chassis": "sıssɐɥƆ pıoΛ",
"block.enderio.wired_charger": "ɹǝbɹɐɥƆ pǝɹıM",
"block.enderio.xp_juice": "ǝɔınſ dX",
"block.enderio.xp_vacuum": "ɯnnɔɐΛ dX",
"description.enderio.enchantment.auto_smelt": "pǝuıɯ sı ɹǝʌǝʇɐɥʍ sʇןǝɯs ʎןןɐɔıʇɐɯoʇnⱯ",
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/enderio/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@
"block.enderio.vibrant_capacitor_bank": "Vibrant Capacitor Bank",
"block.enderio.vibrant_photovoltaic_cell": "Vibrant Photovoltaic Cell",
"block.enderio.void_chassis": "Void Chassis",
"block.enderio.wired_charger": "Wired Charger",
"block.enderio.xp_juice": "Xp Juice",
"block.enderio.xp_vacuum": "Xp Vacuum",
"description.enderio.enchantment.auto_smelt": "Automatically smelts whatever is mined",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"parent": "minecraft:block/block",
"children": {
"frame": {
"parent": "enderio:block/machine_frame"
},
"front": {
"parent": "enderio:block/wired_charger_front"
},
"overlay": {
"parent": "enderio:block/io_overlay"
}
},
"item_render_order": [
"frame",
"overlay",
"front"
],
"loader": "forge:composite",
"textures": {
"particle": "enderio:block/machine_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "enderio:block/wired_charger_front",
"textures": {
"front": "enderio:block/wired_charger_front"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parent": "minecraft:block/block",
"children": {
"frame": {
"parent": "enderio:block/machine_frame"
},
"front": {
"parent": "enderio:block/wired_charger_front",
"textures": {
"front": "enderio:block/wired_charger_front_on"
}
},
"overlay": {
"parent": "enderio:block/io_overlay"
}
},
"item_render_order": [
"frame",
"overlay",
"front"
],
"loader": "forge:composite",
"textures": {
"particle": "enderio:block/machine_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "enderio:block/wired_charger"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_ingredient": {
"conditions": {
"items": [
{
"items": [
"enderio:void_chassis"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "enderio:wired_charger"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_ingredient",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"enderio:wired_charger"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"ops": [
{
"op": "replace",
"source": "",
"target": "BlockEntityTag"
}
],
"source": "block_entity"
}
],
"name": "enderio:wired_charger"
}
],
"rolls": 1.0
}
],
"random_sequence": "enderio:blocks/wired_charger"
}
21 changes: 21 additions & 0 deletions src/generated/resources/data/enderio/recipes/wired_charger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"C": {
"item": "enderio:copper_alloy_ingot"
},
"V": {
"item": "enderio:void_chassis"
}
},
"pattern": [
"CCC",
"CVC",
"CCC"
],
"result": {
"item": "enderio:wired_charger"
},
"show_notification": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"enderio:primitive_alloy_smelter",
"enderio:alloy_smelter",
"enderio:painting_machine",
"enderio:wired_charger",
"enderio:stirling_generator",
"enderio:sag_mill",
"enderio:impulse_hopper",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"enderio:primitive_alloy_smelter",
"enderio:alloy_smelter",
"enderio:painting_machine",
"enderio:wired_charger",
"enderio:stirling_generator",
"enderio:sag_mill",
"enderio:impulse_hopper",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.enderio.machines.client.gui.screen;

import com.enderio.EnderIO;
import com.enderio.api.misc.Vector2i;
import com.enderio.base.common.lang.EIOLang;
import com.enderio.core.client.gui.screen.EIOScreen;
import com.enderio.core.client.gui.widgets.EnumIconWidget;
import com.enderio.machines.client.gui.widget.CapacitorEnergyWidget;
import com.enderio.machines.client.gui.widget.EnergyWidget;
import com.enderio.machines.client.gui.widget.ProgressWidget;
import com.enderio.machines.client.gui.widget.ioconfig.IOConfigButton;
import com.enderio.machines.common.menu.WiredChargerMenu;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;

public class WiredChargerScreen extends EIOScreen<WiredChargerMenu> {

private static final ResourceLocation BG_TEXTURE = EnderIO.loc("textures/gui/wired_charger.png");
public WiredChargerScreen(WiredChargerMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
super(pMenu, pPlayerInventory, pTitle);
}

@Override
protected void init() {
super.init();

addRenderableOnly(new ProgressWidget.BottomUp(this, () -> menu.getBlockEntity().getProgress(), getGuiLeft() + 103, getGuiTop() + 18, 12, 36, 242, 1));

addRenderableOnly(new CapacitorEnergyWidget(this, getMenu().getBlockEntity()::getEnergyStorage, menu.getBlockEntity()::isCapacitorInstalled, 37 + leftPos, 14 + topPos, 9, 42));

addRenderableWidget(new EnumIconWidget<>(this, leftPos + imageWidth - 8 - 12, topPos + 6, () -> menu.getBlockEntity().getRedstoneControl(),
control -> menu.getBlockEntity().setRedstoneControl(control), EIOLang.REDSTONE_MODE));

var inset = new IOConfigButton.Inset(21,0, 0, 0);
addRenderableWidget(new IOConfigButton<>(this, leftPos + imageWidth - 6 - 16, topPos + 22, 16, 16, menu, this::addRenderableWidget, font, inset));
}

@Override
public ResourceLocation getBackgroundImage() {
return BG_TEXTURE;
}

@Override
protected Vector2i getBackgroundImageSize() {
return new Vector2i(197, 166);
}
}