Compare commits

..

3 commits

Author SHA1 Message Date
Flanks255
14c42e6d57 powered furnace done? 2022-01-02 11:03:34 -06:00
Flanks255
48a6f86eb3 powered furnace done? 2022-01-02 10:58:59 -06:00
Flanks255
7357f5b045 Fixed Button to tile packet. 2022-01-02 10:40:49 -06:00
8 changed files with 33 additions and 56 deletions

View file

@ -76,7 +76,7 @@ public class BlockPoweredFurnace extends DirectionalBlock.Container {
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return defaultBlockState().setValue(HORIZONTAL_FACING, context.getNearestLookingDirection().getOpposite()).setValue(LIT, false);
return defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection().getOpposite()).setValue(LIT, false);
}
@Override

View file

@ -22,7 +22,7 @@ public abstract class DirectionalBlock extends BlockBase {
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection().getOpposite());
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
}
@Override
@ -41,7 +41,7 @@ public abstract class DirectionalBlock extends BlockBase {
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection().getOpposite());
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
}
@Override

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.crafting.SingleItem;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPoweredFurnace;
@ -24,6 +25,7 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.network.PacketBuffer;
import javax.annotation.Nonnull;
import java.util.Objects;
public class ContainerFurnaceDouble extends Container {
@ -53,8 +55,9 @@ public class ContainerFurnaceDouble extends Container {
return new ContainerFurnaceDouble(windowId, inv, (TileEntityPoweredFurnace) Objects.requireNonNull(inv.player.level.getBlockEntity(data.readBlockPos())));
}
@Nonnull
@Override
public ItemStack quickMoveStack(PlayerEntity player, int slot) {
public ItemStack quickMoveStack(@Nonnull PlayerEntity player, int slot) {
int inventoryStart = 4;
int inventoryEnd = inventoryStart + 26;
int hotbarStart = inventoryEnd + 1;
@ -76,7 +79,7 @@ public class ContainerFurnaceDouble extends Container {
//Other Slots in Inventory excluded
else if (slot >= inventoryStart) {
// TODO: VALIDATE
IRecipe<?> irecipe = this.furnace.getLevel().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(newStack), this.furnace.getLevel()).orElse(null);
IRecipe<?> irecipe = this.furnace.getLevel().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new SingleItem(newStack), this.furnace.getLevel()).orElse(null);
if (irecipe == null) {
return StackUtil.getEmpty();
}
@ -121,7 +124,7 @@ public class ContainerFurnaceDouble extends Container {
}
@Override
public boolean stillValid(PlayerEntity player) {
public boolean stillValid(@Nonnull PlayerEntity player) {
return this.furnace.canPlayerUse(player);
}
}

View file

@ -30,6 +30,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import javax.annotation.Nonnull;
import javax.xml.soap.Text;
import java.util.Collections;
@OnlyIn(Dist.CLIENT)
@ -67,6 +68,7 @@ public class GuiFurnaceDouble extends AAScreen<ContainerFurnaceDouble> {
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
this.buttonAutoSplit = new Buttons.SmallerButton(this.leftPos, this.topPos, new StringTextComponent("S"), (button) -> PacketHandlerHelper.sendButtonPacket(this.tileFurnace, 0));
buttonAutoSplit.setFGColor(this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN.getColor() : TextFormatting.RED.getColor());
this.addButton(this.buttonAutoSplit);
}
@ -74,21 +76,11 @@ public class GuiFurnaceDouble extends AAScreen<ContainerFurnaceDouble> {
@Override
public void tick() {
super.tick();
this.buttonAutoSplit.setMessage(new StringTextComponent("S").withStyle(this.tileFurnace.isAutoSplit
? TextFormatting.DARK_GREEN
: TextFormatting.RED));
buttonAutoSplit.setFGColor(this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN.getColor() : TextFormatting.RED.getColor());
}
// @Override
// protected void actionPerformed(Button button) throws IOException {
// if (button.id == 0) {
// PacketHandlerHelper.sendButtonPacket(this.tileFurnace, button.id);
// }
// }
@Override
public void renderBg(MatrixStack matrices, float f, int x, int y) {
public void renderBg(@Nonnull MatrixStack matrices, float f, int x, int y) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.getMinecraft().getTextureManager().bind(AssetUtil.GUI_INVENTORY_LOCATION);

View file

@ -33,7 +33,7 @@ public final class PacketHandlerHelper {
compound.putInt("X", pos.getX());
compound.putInt("Y", pos.getY());
compound.putInt("Z", pos.getZ());
compound.putString("WorldID", tile.getLevel().dimension().getRegistryName().toString());
compound.putString("WorldID", tile.getLevel().dimension().location().toString());
compound.putInt("PlayerID", Minecraft.getInstance().player.getId());
compound.putInt("ButtonID", buttonId);
PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));

View file

@ -103,7 +103,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
@Override
public void updateEntity() {
super.updateEntity();
if (!this.level.isClientSide) {
if (!level.isClientSide) {
boolean flag = this.currentBurnTime > 0;
if (this.currentBurnTime > 0 && currentRecipe != null) {
@ -117,16 +117,14 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
if (!this.isRedstonePowered && this.currentBurnTime <= 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()) {
ItemStack stack = this.inv.getStackInSlot(0);
if (!stack.isEmpty()) {
for (SolidFuelRecipe fuelRecipe : ActuallyAdditionsAPI.SOLID_FUEL_RECIPES) {
if (fuelRecipe.matches(stack)) {
this.currentRecipe = fuelRecipe;
this.maxBurnTime = fuelRecipe.getBurnTime();
ActuallyAdditionsAPI.SOLID_FUEL_RECIPES.stream().filter(r -> r.matches(stack)).findFirst().ifPresent(recipe -> {
this.currentRecipe = recipe;
this.maxBurnTime = recipe.getBurnTime();
this.currentBurnTime = this.maxBurnTime;
this.inv.setStackInSlot(0, StackUtil.shrinkForContainer(stack, 1));
break;
}
}
}
});
} else
this.currentRecipe = null;
}
if (flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()) {

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.crafting.SingleItem;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
@ -25,6 +26,7 @@ import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.AbstractCookingRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
@ -37,6 +39,7 @@ import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider {
@ -183,7 +186,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
@Override
public IAcceptor getAcceptor() {
return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && StackUtil.isValid(level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(stack), this.level).map(recipe -> recipe.getResultItem()).orElse(ItemStack.EMPTY));
return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && StackUtil.isValid(level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new SingleItem(stack), this.level).map(AbstractCookingRecipe::getResultItem).orElse(ItemStack.EMPTY));
}
@Override
@ -193,19 +196,16 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
public boolean canSmeltOn(int theInput, int theOutput) {
if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) {
ItemStack output = level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(this.inv.getStackInSlot(theInput)), this.level).map(recipe -> recipe.getResultItem()).orElse(ItemStack.EMPTY);
ItemStack output = level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(this.inv.getStackInSlot(theInput)), this.level).map(AbstractCookingRecipe::getResultItem).orElse(ItemStack.EMPTY);
if (StackUtil.isValid(output)) {
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || this.inv.getStackInSlot(theOutput).sameItem(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount()) {
return true;
return !StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || this.inv.getStackInSlot(theOutput).sameItem(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount();
}
}
}
return false;
}
public void finishBurning(int theInput, int theOutput) {
ItemStack output = level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(this.inv.getStackInSlot(theInput)), this.level).map(recipe -> recipe.getResultItem()).orElse(ItemStack.EMPTY);
ItemStack output = level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(this.inv.getStackInSlot(theInput)), this.level).map(AbstractCookingRecipe::getResultItem).orElse(ItemStack.EMPTY);
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput))) {
this.inv.setStackInSlot(theOutput, output.copy());
} else if (this.inv.getStackInSlot(theOutput).getItem() == output.getItem()) {
@ -236,6 +236,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
return this.lazyEnergy;
}
@Nonnull
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("container.actuallyadditions.furnaceDouble");
@ -243,7 +244,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
@Nullable
@Override
public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) {
public Container createMenu(int windowId, @Nonnull PlayerInventory playerInventory, @Nonnull PlayerEntity player) {
return new ContainerFurnaceDouble(windowId, playerInventory, this);
}
}

View file

@ -88,23 +88,6 @@
"item.banner.actuallyadditionsDrill.magenta": "Magenta Drill Pattern",
"item.banner.actuallyadditionsDrill.orange": "Orange Drill Pattern",
"item.banner.actuallyadditionsDrill.white": "White Drill Pattern",
"_comment": "NEI Integration",
"container.nei.actuallyadditions.crushing": "Crusher",
"container.nei.actuallyadditions.crushingDouble": "Double Crusher",
"container.nei.actuallyadditions.ballOfHair": "Ball Of Fur Usage",
"container.nei.actuallyadditions.compost": "Compost",
"container.nei.actuallyadditions.furnaceDouble": "Powered Furnace",
"container.nei.actuallyadditions.treasureChest": "Treasure Chest",
"container.nei.actuallyadditions.treasureChest.info": "Items at",
"container.nei.actuallyadditions.coffee": "Coffee Maker",
"container.nei.actuallyadditions.coffee.special": "Special Feature",
"container.nei.actuallyadditions.coffee.maxAmount": "Max Amount",
"container.nei.actuallyadditions.coffee.extra.milk": "+01:00, -1 Level",
"container.nei.actuallyadditions.reconstructor": "Atomic Reconstructor",
"container.nei.actuallyadditions.empowerer": "Empowerer",
"container.nei.actuallyadditions.booklet": "Actually Additions Manual",
"container.nei.actuallyadditions.booklet.header": "The <item>Actually Additions Manual<r> says:",
"container.nei.actuallyadditions.booklet.noText": "Nothing, apparently! But that doesn't matter. Just click the button on the bottom to see the item inside the booklet and look through its pages to find some fancy stuff!",
"_comment": "Damage Sources",
"death.actuallyadditions.atomicReconstructor.1": "%s got atomically reconstructed.",
"death.actuallyadditions.atomicReconstructor.2": "The Atomic Reconstructor caught %s in its sight.",
@ -123,7 +106,7 @@
"block.actuallyadditions.giant_chest_large": "Large Storage Crate",
"block.actuallyadditions.crusher": "Crusher",
"block.actuallyadditions.double_crusher": "Double Crusher",
"block.actuallyadditions.furnace_double": "Powered Furnace",
"block.actuallyadditions.powered_furnace": "Powered Furnace",
"block.actuallyadditions.fishing_net": "Fishing Net",
"block.actuallyadditions.furnace_solar": "Solar Panel",
"block.actuallyadditions.heat_collector": "Heat Collector",