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

[7.2] Remove the primitive alloy smelter #975

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"block.enderio.painting_machine": "Painting Machine",
"block.enderio.powered_spawner": "Powered Spawner",
"block.enderio.pressurized_fluid_tank": "Pressurized Fluid Tank",
"block.enderio.primitive_alloy_smelter": "Primitive Alloy Smelter",
"block.enderio.pulsating_photovoltaic_module": "Pulsating Photovoltaic Module",
"block.enderio.relocator_obelisk": "Relocator Obelisk",
"block.enderio.sag_mill": "SAG Mill",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"enderio:fluid_tank",
"enderio:pressurized_fluid_tank",
"enderio:enchanter",
"enderio:primitive_alloy_smelter",
"enderio:alloy_smelter",
"enderio:painting_machine",
"enderio:wired_charger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"enderio:fluid_tank",
"enderio:pressurized_fluid_tank",
"enderio:enchanter",
"enderio:primitive_alloy_smelter",
"enderio:alloy_smelter",
"enderio:painting_machine",
"enderio:wired_charger",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.common.crafting.SizedIngredient;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -63,14 +62,9 @@ public class AlloySmelterBlockEntity extends PoweredMachineBlockEntity {

private static final Logger LOGGER = LogUtils.getLogger();

public static AlloySmelterBlockEntity factory(BlockPos pWorldPosition, BlockState pBlockState) {
return new AlloySmelterBlockEntity(MachineBlockEntities.ALLOY_SMELTER.get(), pWorldPosition, pBlockState,
CapacitorSupport.REQUIRED);
}

protected AlloySmelterBlockEntity(BlockEntityType<?> pType, BlockPos pWorldPosition, BlockState pBlockState,
CapacitorSupport capacitorSupport) {
super(pType, pWorldPosition, pBlockState, true, capacitorSupport, EnergyIOMode.Input, CAPACITY, USAGE);
public AlloySmelterBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) {
super(MachineBlockEntities.ALLOY_SMELTER.get(), pWorldPosition, pBlockState, true, CapacitorSupport.REQUIRED,
EnergyIOMode.Input, CAPACITY, USAGE);

// Crafting task host
craftingTaskHost = new AlloySmeltingMachineTaskHost(this, this::canAcceptTask,
Expand Down Expand Up @@ -117,26 +111,6 @@ public void onLoad() {
craftingTaskHost.onLevelReady();
}

// region Primitive Smelter Shims

/**
* Whether the mode is restricted.
* Used to disable serialization of the mode and sync of the slot when this is the primitive variant.
*/
public boolean isPrimitiveSmelter() {
return false;
}

protected MultiSlotAccess getInputsSlotAccess() {
return INPUTS;
}

protected SingleSlotAccess getOutputSlotAccess() {
return OUTPUT;
}

// endregion

// region Inventory

@Override
Expand All @@ -152,15 +126,14 @@ public MachineInventoryLayout createInventoryLayout() {

protected boolean acceptSlotInput(int slot, ItemStack stack) {
if (getMode().canAlloy()) {
if (RecipeCaches.ALLOY_SMELTING_ONLY_ALLOY.hasValidRecipeIf(getInventory(), getInputsSlotAccess(), slot,
stack)) {
if (RecipeCaches.ALLOY_SMELTING_ONLY_ALLOY.hasValidRecipeIf(getInventory(), INPUTS, slot, stack)) {
return true;
}
}

if (getMode().canSmelt()) {
// Check all items are the same, or will be
var currentStacks = getInputsSlotAccess().getAccesses()
var currentStacks = INPUTS.getAccesses()
.stream()
.map(i -> i.isSlot(slot) ? stack : i.getItemStack(getInventory()))
.filter(i -> !i.isEmpty())
Expand All @@ -181,7 +154,7 @@ protected void onInventoryContentsChanged(int slot) {
}

private AlloySmeltingRecipe.Input createRecipeInput() {
return new AlloySmeltingRecipe.Input(getInputsSlotAccess().getItemStacks(getInventory()), 1);
return new AlloySmeltingRecipe.Input(INPUTS.getItemStacks(getInventory()), 1);
}

// endregion
Expand All @@ -199,8 +172,8 @@ public boolean isActive() {

protected AlloySmeltingMachineTask createTask(Level level, AlloySmeltingRecipe.Input recipeInput,
@Nullable RecipeHolder<AlloySmeltingRecipe> recipe) {
return new AlloySmeltingMachineTask(level, getInventory(), getEnergyStorage(), recipeInput,
getInputsSlotAccess(), getOutputSlotAccess(), recipe);
return new AlloySmeltingMachineTask(level, getInventory(), getEnergyStorage(), recipeInput, INPUTS, OUTPUT,
recipe);
}

protected static class AlloySmeltingMachineTask
Expand Down Expand Up @@ -338,26 +311,20 @@ protected Optional<RecipeHolder<AlloySmeltingRecipe>> findRecipe() {
@Override
public void saveAdditional(CompoundTag pTag, HolderLookup.Provider lookupProvider) {
craftingTaskHost.save(lookupProvider, pTag);

if (!isPrimitiveSmelter()) {
pTag.putInt(MachineNBTKeys.MACHINE_MODE, this.mode.ordinal());
}

pTag.putInt(MachineNBTKeys.MACHINE_MODE, this.mode.ordinal());
super.saveAdditional(pTag, lookupProvider);
}

@Override
public void loadAdditional(CompoundTag pTag, HolderLookup.Provider lookupProvider) {
craftingTaskHost.load(lookupProvider, pTag);

if (!isPrimitiveSmelter()) {
try {
mode = AlloySmelterMode.values()[pTag.getInt(MachineNBTKeys.MACHINE_MODE)];
} catch (IndexOutOfBoundsException ex) { // In case something happens in the future.
LOGGER.error("Invalid alloy smelter mode loaded from NBT. Ignoring.");
}
// TODO: EnderIO 8 - swap to serializing the enum name.
try {
mode = AlloySmelterMode.values()[pTag.getInt(MachineNBTKeys.MACHINE_MODE)];
} catch (IndexOutOfBoundsException ex) { // In case something happens in the future.
LOGGER.error("Invalid alloy smelter mode loaded from NBT. Ignoring.");
}

super.loadAdditional(pTag, lookupProvider);
}

Expand All @@ -366,19 +333,13 @@ protected void applyImplicitComponents(DataComponentInput components) {
super.applyImplicitComponents(components);

// TODO: 1.21: Write crafting host into the item components.

if (!isPrimitiveSmelter()) {
mode = components.getOrDefault(MachineDataComponents.ALLOY_SMELTER_MODE, AlloySmelterMode.ALL);
}
mode = components.getOrDefault(MachineDataComponents.ALLOY_SMELTER_MODE, AlloySmelterMode.ALL);
}

@Override
protected void collectImplicitComponents(DataComponentMap.Builder components) {
super.collectImplicitComponents(components);

if (!isPrimitiveSmelter()) {
components.set(MachineDataComponents.ALLOY_SMELTER_MODE, mode);
}
components.set(MachineDataComponents.ALLOY_SMELTER_MODE, mode);
}

@Override
Expand Down
Loading