Merge remote-tracking branch 'remotes/origin/1.12' into 1.13-prep
# Conflicts: # src/main/java/techreborn/compat/immersiveengineering/RecipeImmersiveEngineering.java # src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java # src/main/java/techreborn/init/ModRecipes.java # src/main/java/techreborn/packets/PacketAutoCraftingTableLock.java
|
@ -35,7 +35,7 @@ repositories {
|
|||
}
|
||||
}
|
||||
|
||||
version = "2.16.0"
|
||||
version = "2.16.2"
|
||||
|
||||
def ENV = System.getenv()
|
||||
if (ENV.BUILD_NUMBER) {
|
||||
|
|
|
@ -185,9 +185,9 @@ public class Core {
|
|||
public void LoadPackets(RegisterPacketEvent event) {
|
||||
event.registerPacket(PacketAesu.class, Side.SERVER);
|
||||
event.registerPacket(PacketIdsu.class, Side.SERVER);
|
||||
event.registerPacket(PacketSetRecipe.class, Side.SERVER);
|
||||
event.registerPacket(PacketRollingMachineLock.class, Side.SERVER);
|
||||
event.registerPacket(PacketFusionControlSize.class, Side.SERVER);
|
||||
event.registerPacket(PacketAutoCraftingTableLock.class, Side.SERVER);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BlockOre2 extends Block implements IOreNameProvider {
|
|||
|
||||
public static final String[] ores = new String[] { "copper", "tin" };
|
||||
static List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores));
|
||||
public PropertyString VARIANTS = new PropertyString("type", oreNamesList);
|
||||
public PropertyString VARIANTS;
|
||||
|
||||
public BlockOre2() {
|
||||
super(Material.ROCK);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
|||
public BlockPlayerDetector() {
|
||||
super(true);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
this.setDefaultState(this.getDefaultState().withProperty(TYPE, "all"));
|
||||
this.setDefaultState(this.getStateFromMeta(0));
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
RebornModelRegistry.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/tier1_machines").setInvVariant("type=" + types[i]));
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import net.minecraftforge.fml.common.network.IGuiHandler;
|
|||
import techreborn.client.container.ContainerDestructoPack;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.gui.*;
|
||||
import techreborn.client.gui.autocrafting.GuiAutoCrafting;
|
||||
import techreborn.client.gui.GuiAutoCrafting;
|
||||
import techreborn.tiles.*;
|
||||
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
|
||||
import techreborn.tiles.generator.*;
|
||||
|
|
116
src/main/java/techreborn/client/gui/GuiAutoCrafting.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import techreborn.packets.PacketAutoCraftingTableLock;
|
||||
import techreborn.tiles.tier1.TileAutoCraftingTable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static net.minecraft.item.ItemStack.EMPTY;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 20/06/2017.
|
||||
*/
|
||||
public class GuiAutoCrafting extends GuiBase {
|
||||
|
||||
static final ResourceLocation RECIPE_BOOK_TEXTURE = new ResourceLocation("textures/gui/recipe_book.png");
|
||||
boolean showGui = true;
|
||||
TileAutoCraftingTable tileAutoCraftingTable;
|
||||
|
||||
public GuiAutoCrafting(EntityPlayer player, TileAutoCraftingTable tile) {
|
||||
super(player, tile, tile.createContainer(player));
|
||||
this.tileAutoCraftingTable = tile;
|
||||
}
|
||||
|
||||
public void renderItemStack(ItemStack stack, int x, int y) {
|
||||
if (stack != EMPTY) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.color(1, 1, 1, 1F / 3F);
|
||||
drawRect(x - 4, y- 4, x + 20, y + 20, -2139062144);
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
IRecipe recipe = tileAutoCraftingTable.getIRecipe();
|
||||
if (recipe != null) {
|
||||
renderItemStack(recipe.getRecipeOutput(), 95, 42);
|
||||
}
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
this.builder.drawMultiEnergyBar(this, 9, 26, (int) this.tileAutoCraftingTable.getEnergy(), (int) this.tileAutoCraftingTable.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
this.builder.drawProgressBar(this, tileAutoCraftingTable.getProgress(), tileAutoCraftingTable.getMaxProgress(), 120, 44, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(final float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
final Layer layer = Layer.BACKGROUND;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
drawSlot(28 + (i * 18), 25 + (j * 18), layer);
|
||||
}
|
||||
}
|
||||
drawOutputSlot(145, 42, layer);
|
||||
drawOutputSlot(95, 42, layer);
|
||||
drawString("Inventory", 8, 82, 4210752, layer);
|
||||
|
||||
this.builder.drawLockButton(this, 145, 4, mouseX, mouseY, layer, tileAutoCraftingTable.locked);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if (this.builder.isInRect(145 + getGuiLeft(), 4 + getGuiTop(), 20, 12, mouseX, mouseY)) {
|
||||
NetworkManager.sendToServer(new PacketAutoCraftingTableLock(tileAutoCraftingTable, !tileAutoCraftingTable.locked));
|
||||
return;
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
|
@ -135,8 +135,9 @@ public class GuiBase extends GuiContainer {
|
|||
upgrades = true;
|
||||
}
|
||||
}
|
||||
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY, upgrades);
|
||||
|
||||
if(getMachine().hasSlotConfig()){
|
||||
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY, upgrades);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean drawPlayerSlots() {
|
||||
|
@ -152,7 +153,7 @@ public class GuiBase extends GuiContainer {
|
|||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.buttonList.clear();
|
||||
drawTitle();
|
||||
if(showSlotConfig){
|
||||
if(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
GuiSlotConfiguration.draw(this, mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
@ -160,7 +161,7 @@ public class GuiBase extends GuiContainer {
|
|||
if(!upgrades){
|
||||
offset = 80;
|
||||
}
|
||||
if (builder.isInRect(guiLeft - 19, guiTop + 92 - offset, 12, 12, mouseX, mouseY)) {
|
||||
if (builder.isInRect(guiLeft - 19, guiTop + 92 - offset, 12, 12, mouseX, mouseY) && getMachine().hasSlotConfig()) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Configure slots");
|
||||
GuiUtils.drawHoveringText(list, mouseX - guiLeft , mouseY - guiTop , width, height, -1, mc.fontRenderer);
|
||||
|
@ -211,7 +212,7 @@ public class GuiBase extends GuiContainer {
|
|||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if(showSlotConfig){
|
||||
if(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
if(GuiSlotConfiguration.mouseClicked(mouseX, mouseY, mouseButton, this)){
|
||||
return;
|
||||
}
|
||||
|
@ -221,7 +222,7 @@ public class GuiBase extends GuiContainer {
|
|||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
if(showSlotConfig){
|
||||
if(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
GuiSlotConfiguration.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick, this);
|
||||
}
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
|
@ -233,13 +234,13 @@ public class GuiBase extends GuiContainer {
|
|||
if(!upgrades){
|
||||
offset = 80;
|
||||
}
|
||||
if(isPointInRegion(-26, 84 - offset, 30, 30, mouseX, mouseY)){
|
||||
if(isPointInRegion(-26, 84 - offset, 30, 30, mouseX, mouseY) && getMachine().hasSlotConfig()){
|
||||
showSlotConfig = !showSlotConfig;
|
||||
if(!showSlotConfig){
|
||||
GuiSlotConfiguration.reset();
|
||||
}
|
||||
}
|
||||
if(showSlotConfig){
|
||||
if(showSlotConfig && getMachine().hasSlotConfig()){
|
||||
if(GuiSlotConfiguration.mouseReleased(mouseX, mouseY, state, this)){
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,245 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.autocrafting;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import techreborn.packets.PacketSetRecipe;
|
||||
import techreborn.tiles.tier1.TileAutoCraftingTable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.item.ItemStack.EMPTY;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 20/06/2017.
|
||||
*/
|
||||
public class GuiAutoCrafting extends GuiBase {
|
||||
|
||||
static final ResourceLocation RECIPE_BOOK_TEXTURE = new ResourceLocation("textures/gui/recipe_book.png");
|
||||
GuiAutoCraftingRecipeSlector recipeSlector = new GuiAutoCraftingRecipeSlector();
|
||||
boolean showGui = true;
|
||||
InventoryCrafting dummyInv;
|
||||
TileAutoCraftingTable tileAutoCraftingTable;
|
||||
|
||||
public GuiAutoCrafting(EntityPlayer player, TileAutoCraftingTable tile) {
|
||||
super(player, tile, tile.createContainer(player));
|
||||
this.tileAutoCraftingTable = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
recipeSlector.tick();
|
||||
}
|
||||
|
||||
public void renderItemStack(ItemStack stack, int x, int y) {
|
||||
if (stack != EMPTY) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
IRecipe recipe = tileAutoCraftingTable.getIRecipe();
|
||||
if (recipe != null) {
|
||||
renderItemStack(recipe.getRecipeOutput(), 95, 42);
|
||||
}
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
this.builder.drawMultiEnergyBar(this, 9, 26, (int) this.tileAutoCraftingTable.getEnergy(), (int) this.tileAutoCraftingTable.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
this.builder.drawProgressBar(this, tileAutoCraftingTable.getProgress(), tileAutoCraftingTable.getMaxProgress(), 120, 44, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
|
||||
|
||||
int mX = mouseX - getGuiLeft();
|
||||
int mY = mouseY - getGuiTop();
|
||||
|
||||
if (recipe != null && !tileAutoCraftingTable.customRecipe) {
|
||||
if (builder.isInRect(91, 66, 23, 23, mX, mY)) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Click to clear");
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mX, mY, width, height, -1, mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Based of vanilla code
|
||||
public void renderRecipe(IRecipe recipe, int x, int y) {
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.enableAlpha();
|
||||
mc.getTextureManager().bindTexture(RECIPE_BOOK_TEXTURE);
|
||||
|
||||
this.drawTexturedModalRect(x, y, 152, 78, 24, 24);
|
||||
|
||||
int recipeWidth = 3;
|
||||
int recipeHeight = 3;
|
||||
if (recipe instanceof ShapedRecipes) {
|
||||
ShapedRecipes shapedrecipes = (ShapedRecipes) recipe;
|
||||
recipeWidth = shapedrecipes.getWidth();
|
||||
recipeHeight = shapedrecipes.getHeight();
|
||||
}
|
||||
if (recipe instanceof ShapedOreRecipe) {
|
||||
ShapedOreRecipe shapedrecipes = (ShapedOreRecipe) recipe;
|
||||
recipeWidth = shapedrecipes.getRecipeWidth();
|
||||
recipeHeight = shapedrecipes.getRecipeHeight();
|
||||
}
|
||||
Iterator<Ingredient> ingredients = recipe.getIngredients().iterator();
|
||||
for (int rHeight = 0; rHeight < recipeHeight; ++rHeight) {
|
||||
int j1 = 3 + rHeight * 7;
|
||||
for (int rWidth = 0; rWidth < recipeWidth; ++rWidth) {
|
||||
if (ingredients.hasNext()) {
|
||||
ItemStack[] aitemstack = ingredients.next().getMatchingStacks();
|
||||
if (aitemstack.length != 0) {
|
||||
int l1 = 3 + rWidth * 7;
|
||||
GlStateManager.pushMatrix();
|
||||
int i2 = (int) ((float) (x + l1) / 0.42F - 3.0F);
|
||||
int j2 = (int) ((float) (y + j1) / 0.42F - 3.0F);
|
||||
GlStateManager.scale(0.42F, 0.42F, 1.0F);
|
||||
GlStateManager.enableLighting();
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(aitemstack[0], i2, j2);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GlStateManager.disableAlpha();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(final float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
final Layer layer = Layer.BACKGROUND;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
drawSlot(28 + (i * 18), 25 + (j * 18), layer);
|
||||
}
|
||||
}
|
||||
drawOutputSlot(145, 42, layer);
|
||||
drawOutputSlot(95, 42, layer);
|
||||
drawString("Inventory", 8, 82, 4210752, layer);
|
||||
|
||||
IRecipe recipe = tileAutoCraftingTable.getIRecipe();
|
||||
if (recipe != null && !tileAutoCraftingTable.customRecipe) {
|
||||
renderRecipe(recipe, guiLeft + 91, 66 + guiTop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
recipeSlector.setGuiAutoCrafting(this);
|
||||
dummyInv = new InventoryCrafting(new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn) {
|
||||
return false;
|
||||
}
|
||||
}, 3, 3);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
dummyInv.setInventorySlotContents(i, ItemStack.EMPTY);
|
||||
}
|
||||
this.recipeSlector.func_194303_a(this.width, this.height, Minecraft.getMinecraft(), false, dummyInv);
|
||||
this.guiLeft = this.recipeSlector.updateScreenPosition(false, this.width, this.xSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
if (showGui) {
|
||||
this.recipeSlector.render(mouseX, mouseY, 0.1F);
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.recipeSlector.renderGhostRecipe(this.guiLeft, this.guiTop, false, partialTicks);
|
||||
} else {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
this.recipeSlector.renderTooltip(this.guiLeft, this.guiTop, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if (!this.recipeSlector.mouseClicked(mouseX, mouseY, mouseButton)) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
int mX = mouseX - getGuiLeft();
|
||||
int mY = mouseY - getGuiTop();
|
||||
|
||||
mc.getTextureManager().bindTexture(TRBuilder.GUI_SHEET);
|
||||
if (builder.isInRect(91, 66, 23, 23, mX, mY)) {
|
||||
setRecipe(null, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if (!this.recipeSlector.keyPressed(typedChar, keyCode)) {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(Slot slotIn, int slotId, int mouseButton, ClickType type) {
|
||||
super.handleMouseClick(slotIn, slotId, mouseButton, type);
|
||||
this.recipeSlector.slotClicked(slotIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
this.recipeSlector.removed();
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
public void setRecipe(IRecipe recipe, boolean custom) {
|
||||
tileAutoCraftingTable.setCurrentRecipe(recipe, custom);
|
||||
NetworkManager.sendToServer(new PacketSetRecipe(tileAutoCraftingTable, recipe, custom));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui.autocrafting;
|
||||
|
||||
import net.minecraft.client.gui.GuiButtonToggle;
|
||||
import net.minecraft.client.gui.recipebook.GuiRecipeBook;
|
||||
import net.minecraft.client.gui.recipebook.RecipeList;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 20/06/2017.
|
||||
*/
|
||||
public class GuiAutoCraftingRecipeSlector extends GuiRecipeBook {
|
||||
|
||||
GuiAutoCrafting guiAutoCrafting;
|
||||
|
||||
@Override
|
||||
public void initVisuals(boolean p_193014_1_, InventoryCrafting p_193014_2_) {
|
||||
super.initVisuals(p_193014_1_, p_193014_2_);
|
||||
//Pulls the button off the screen as we dont need it
|
||||
toggleRecipesBtn = new GuiButtonToggle(0, -1000, -1000, 26, 16, false);
|
||||
toggleRecipesBtn.initTextureValues(152, 41, 28, 18, RECIPE_BOOK);
|
||||
//recipeBook.setGuiOpen(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setContainerRecipe(IRecipe recipe) {
|
||||
guiAutoCrafting.setRecipe(recipe, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int p_191862_1_, int p_191862_2_, int p_191862_3_) {
|
||||
if (this.isVisible()) {
|
||||
if (this.recipeBookPage.mouseClicked(p_191862_1_, p_191862_2_, p_191862_3_, (this.width - 147) / 2 - this.xOffset, (this.height - 166) / 2, 147, 166)) {
|
||||
IRecipe irecipe = this.recipeBookPage.getLastClickedRecipe();
|
||||
RecipeList recipelist = this.recipeBookPage.getLastClickedRecipeList();
|
||||
|
||||
if (irecipe != null && recipelist != null) {
|
||||
if (!recipelist.isCraftable(irecipe) && this.ghostRecipe.getRecipe() == irecipe) {
|
||||
return false;
|
||||
}
|
||||
this.ghostRecipe.clear();
|
||||
setContainerRecipe(irecipe);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.mouseClicked(p_191862_1_, p_191862_2_, p_191862_3_);
|
||||
}
|
||||
|
||||
public void setGuiAutoCrafting(GuiAutoCrafting guiAutoCrafting) {
|
||||
this.guiAutoCrafting = guiAutoCrafting;
|
||||
}
|
||||
}
|
|
@ -233,6 +233,11 @@ public class ModRecipes {
|
|||
ItemDusts.getDustByName("obsidian", 4),
|
||||
170, 19));
|
||||
|
||||
RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
|
||||
new ItemStack(Items.BLAZE_ROD),
|
||||
new ItemStack(Items.BLAZE_POWDER, 4),
|
||||
170, 19));
|
||||
|
||||
if (OreUtil.doesOreExistAndValid("stoneMarble")) {
|
||||
ItemStack marbleStack = getOre("stoneMarble");
|
||||
marbleStack.setCount(1);
|
||||
|
@ -248,7 +253,7 @@ public class ModRecipes {
|
|||
120, 10));
|
||||
}
|
||||
|
||||
//See comments bellow, this allows the ore to go to the product when it sometimes goes stright to dust.
|
||||
//See comments bellow, this allows the ore to go to the product when it sometimes goes straight to dust.
|
||||
RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
|
||||
"oreCoal", new ItemStack(Items.COAL, 2),
|
||||
270, 31));
|
||||
|
|
|
@ -242,7 +242,10 @@ public class DynamicCell extends Item {
|
|||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void setContainerToEmpty() {
|
||||
container = new ItemStack(ModItems.CELL, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,56 +24,46 @@
|
|||
|
||||
package techreborn.packets;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import reborncore.common.network.ExtendedPacketBuffer;
|
||||
import reborncore.common.network.INetworkPacket;
|
||||
import techreborn.tiles.tier1.TileAutoCraftingTable;
|
||||
import techreborn.tiles.tier1.TileRollingMachine;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 20/06/2017.
|
||||
*/
|
||||
public class PacketSetRecipe implements INetworkPacket {
|
||||
import java.io.IOException;
|
||||
|
||||
BlockPos pos;
|
||||
ResourceLocation recipe;
|
||||
boolean custom;
|
||||
public class PacketAutoCraftingTableLock implements INetworkPacket {
|
||||
|
||||
public PacketSetRecipe(TileAutoCraftingTable tile, IRecipe recipe, boolean custom) {
|
||||
this.pos = tile.getPos();
|
||||
if (recipe == null) {
|
||||
this.recipe = new ResourceLocation("");
|
||||
} else {
|
||||
this.recipe = recipe.getRegistryName();
|
||||
}
|
||||
this.custom = custom;
|
||||
BlockPos machinePos;
|
||||
boolean locked;
|
||||
|
||||
public PacketAutoCraftingTableLock(TileAutoCraftingTable machine, boolean locked) {
|
||||
this.machinePos = machine.getPos();
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public PacketSetRecipe() {
|
||||
public PacketAutoCraftingTableLock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(ExtendedPacketBuffer buffer) {
|
||||
buffer.writeBlockPos(pos);
|
||||
buffer.writeResourceLocation(recipe);
|
||||
buffer.writeBoolean(custom);
|
||||
buffer.writeBlockPos(machinePos);
|
||||
buffer.writeBoolean(locked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ExtendedPacketBuffer buffer) {
|
||||
pos = buffer.readBlockPos();
|
||||
recipe = buffer.readResourceLocation();
|
||||
custom = buffer.readBoolean();
|
||||
public void readData(ExtendedPacketBuffer buffer) {
|
||||
machinePos = buffer.readBlockPos();
|
||||
locked = buffer.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MessageContext context) {
|
||||
TileEntity tileEntity = context.getServerHandler().player.world.getTileEntity(pos);
|
||||
if (tileEntity instanceof TileAutoCraftingTable) {
|
||||
((TileAutoCraftingTable) tileEntity).setCurrentRecipe(recipe, custom);
|
||||
TileEntity tileEntity = context.getServerHandler().player.world.getTileEntity(machinePos);
|
||||
if(tileEntity instanceof TileAutoCraftingTable){
|
||||
((TileAutoCraftingTable) tileEntity).locked = locked;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ public class TileMatterFabricator extends TilePowerAcceptor
|
|||
@ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorMaxInput", comment = "Matter Fabricator Max Input (Value in EU)")
|
||||
public static int maxInput = 8192;
|
||||
@ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorMaxEnergy", comment = "Matter Fabricator Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 100_000_000;
|
||||
public static int maxEnergy = 10_000_000;
|
||||
@ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorFabricationRate", comment = "Matter Fabricator Fabrication Rate, amount of amplifier units per UUM")
|
||||
public static int fabricationRate = 6_000;
|
||||
@ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorEnergyPerAmp", comment = "Matter Fabricator EU per amplifier unit, multiply this with the rate for total EU")
|
||||
|
|
|
@ -118,14 +118,15 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
if (!getStackInSlot(1).isEmpty()) {
|
||||
stacks.add(getStackInSlot(1));
|
||||
}
|
||||
for (int i = 0; i < getStoredCount() / 64; i++) {
|
||||
int size = storedItem.getMaxStackSize();
|
||||
for (int i = 0; i < getStoredCount() / size; i++) {
|
||||
ItemStack droped = storedItem.copy();
|
||||
droped.setCount(64);
|
||||
droped.setCount(size);
|
||||
stacks.add(droped);
|
||||
}
|
||||
if (getStoredCount() % 64 != 0) {
|
||||
if (getStoredCount() % size != 0) {
|
||||
ItemStack droped = storedItem.copy();
|
||||
droped.setCount(getStoredCount() % 64);
|
||||
droped.setCount(getStoredCount() % size);
|
||||
stacks.add(droped);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.tile.SlotConfiguration;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
|
@ -55,80 +55,52 @@ import techreborn.lib.ModInfo;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 20/06/2017.
|
||||
*/
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class TileAutoCraftingTable extends TilePowerAcceptor
|
||||
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
||||
|
||||
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "machines", category = "autocrafter", key = "AutoCrafterInput", comment = "AutoCrafting Table Max Input (Value in EU)")
|
||||
public static int maxInput = 32;
|
||||
@ConfigRegistry(config = "machines", category = "autocrafter", key = "AutoCrafterMaxEnergy", comment = "AutoCrafting Table Max Energy (Value in EU)")
|
||||
public static int maxEnergy = 10_000;
|
||||
|
||||
ResourceLocation currentRecipe;
|
||||
|
||||
public Inventory inventory = new Inventory(11, "TileAutoCraftingTable", 64, this);
|
||||
public int progress;
|
||||
public int maxProgress = 120;
|
||||
public int euTick = 10;
|
||||
public Pair<ResourceLocation, IRecipe> cachedRecipe;
|
||||
public boolean customRecipe = false;
|
||||
|
||||
InventoryCrafting inventoryCrafting = null;
|
||||
IRecipe lastCustomRecipe = null;
|
||||
|
||||
IRecipe lastRecipe = null;
|
||||
|
||||
public boolean locked = true;
|
||||
|
||||
public TileAutoCraftingTable() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setCurrentRecipe(IRecipe recipe, boolean customRecipe) {
|
||||
if (recipe != null) {
|
||||
currentRecipe = recipe.getRegistryName();
|
||||
} else {
|
||||
currentRecipe = null;
|
||||
}
|
||||
|
||||
// Disabled due to performance issues
|
||||
//this.customRecipe = customRecipe;
|
||||
this.customRecipe = false;
|
||||
cachedRecipe = null;
|
||||
}
|
||||
|
||||
public void setCurrentRecipe(ResourceLocation recipe, boolean customRecipe) {
|
||||
currentRecipe = recipe;
|
||||
// Disabled due to performance issues
|
||||
//this.customRecipe = customRecipe;
|
||||
this.customRecipe = false;
|
||||
cachedRecipe = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IRecipe getIRecipe() {
|
||||
if (customRecipe) {
|
||||
InventoryCrafting crafting = getCraftingInventory();
|
||||
if(!crafting.isEmpty()){
|
||||
for (IRecipe testRecipe : CraftingManager.REGISTRY) {
|
||||
if (testRecipe.matches(crafting, world)) {
|
||||
return testRecipe;
|
||||
}
|
||||
InventoryCrafting crafting = getCraftingInventory();
|
||||
if (!crafting.isEmpty()) {
|
||||
if(lastRecipe != null){
|
||||
if(lastRecipe.matches(crafting, world)){
|
||||
return lastRecipe;
|
||||
}
|
||||
}
|
||||
for (IRecipe testRecipe : CraftingManager.REGISTRY) {
|
||||
if (testRecipe.matches(crafting, world)) {
|
||||
lastRecipe = testRecipe;
|
||||
return testRecipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentRecipe == null) {
|
||||
return null;
|
||||
}
|
||||
if (cachedRecipe == null || !cachedRecipe.getLeft().equals(currentRecipe)) {
|
||||
IRecipe recipe = ForgeRegistries.RECIPES.getValue(currentRecipe);
|
||||
if (recipe != null) {
|
||||
cachedRecipe = Pair.of(currentRecipe, recipe);
|
||||
return recipe;
|
||||
}
|
||||
cachedRecipe = null;
|
||||
return null;
|
||||
}
|
||||
return cachedRecipe.getRight();
|
||||
return null;
|
||||
}
|
||||
|
||||
public InventoryCrafting getCraftingInventory() {
|
||||
|
@ -145,11 +117,8 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
}
|
||||
return inventoryCrafting;
|
||||
}
|
||||
|
||||
|
||||
public boolean canMake(IRecipe recipe) {
|
||||
if (customRecipe) {
|
||||
recipe = getIRecipe();
|
||||
}
|
||||
if (recipe != null && recipe.canFit(3, 3)) {
|
||||
boolean missingOutput = false;
|
||||
int[] stacksInSlots = new int[9];
|
||||
|
@ -161,14 +130,14 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
boolean foundIngredient = false;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
int requiredSize = customRecipe ? 1 : 0;
|
||||
if(stack.getMaxStackSize() == 1){
|
||||
int requiredSize = locked ? 1 : 0;
|
||||
if (stack.getMaxStackSize() == 1) {
|
||||
requiredSize = 0;
|
||||
}
|
||||
if (stacksInSlots[i] > requiredSize) {
|
||||
if (ingredient.apply(stack)) {
|
||||
if(stack.getItem().getContainerItem() != null){
|
||||
if(!hasRoomForExtraItem(stack.getItem().getContainerItem(stack))){
|
||||
if (stack.getItem().getContainerItem() != null) {
|
||||
if (!hasRoomForExtraItem(stack.getItem().getContainerItem(stack))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -193,9 +162,9 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean hasRoomForExtraItem(ItemStack stack){
|
||||
boolean hasRoomForExtraItem(ItemStack stack) {
|
||||
ItemStack extraOutputSlot = getStackInSlot(10);
|
||||
if(extraOutputSlot.isEmpty()){
|
||||
if (extraOutputSlot.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return hasOutputSpace(stack, 10);
|
||||
|
@ -215,17 +184,12 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
}
|
||||
|
||||
public boolean make(IRecipe recipe) {
|
||||
IRecipe recipe2 = recipe;
|
||||
if (canMake(recipe2)) {
|
||||
if (recipe2 == null && customRecipe) {
|
||||
if (lastCustomRecipe == null) {
|
||||
return false;
|
||||
}//Should be uptodate as we just set it in canMake
|
||||
recipe = lastCustomRecipe;
|
||||
}
|
||||
else if (recipe2 != null) {
|
||||
for (int i = 0; i < recipe2.getIngredients().size(); i++) {
|
||||
Ingredient ingredient = recipe2.getIngredients().get(i);
|
||||
if (canMake(recipe)) {
|
||||
if (recipe == null) {
|
||||
return false;
|
||||
} else if (recipe != null) {
|
||||
for (int i = 0; i < recipe.getIngredients().size(); i++) {
|
||||
Ingredient ingredient = recipe.getIngredients().get(i);
|
||||
//Looks for the best slot to take it from
|
||||
ItemStack bestSlot = inventory.getStackInSlot(i);
|
||||
if (ingredient.apply(bestSlot)) {
|
||||
|
@ -244,12 +208,12 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
}
|
||||
ItemStack output = inventory.getStackInSlot(9);
|
||||
//TODO fire forge recipe event
|
||||
ItemStack ouputStack = recipe2.getCraftingResult(getCraftingInventory());
|
||||
ItemStack ouputStack = recipe.getCraftingResult(getCraftingInventory());
|
||||
if (output.isEmpty()) {
|
||||
inventory.setInventorySlotContents(9, ouputStack.copy());
|
||||
} else {
|
||||
//TODO use ouputStack in someway?
|
||||
output.grow(recipe2.getRecipeOutput().getCount());
|
||||
output.grow(recipe.getRecipeOutput().getCount());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -257,14 +221,14 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
return false;
|
||||
}
|
||||
|
||||
private void handleContainerItem(ItemStack stack){
|
||||
if(stack.getItem().hasContainerItem(stack)){
|
||||
private void handleContainerItem(ItemStack stack) {
|
||||
if (stack.getItem().hasContainerItem(stack)) {
|
||||
ItemStack containerItem = stack.getItem().getContainerItem(stack);
|
||||
ItemStack extraOutputSlot = getStackInSlot(10);
|
||||
if(hasOutputSpace(containerItem, 10)){
|
||||
if(extraOutputSlot.isEmpty()){
|
||||
if (hasOutputSpace(containerItem, 10)) {
|
||||
if (extraOutputSlot.isEmpty()) {
|
||||
setInventorySlotContents(10, containerItem.copy());
|
||||
} else if(ItemUtils.isItemEqual(extraOutputSlot, containerItem, true, true) && extraOutputSlot.getMaxStackSize() < extraOutputSlot.getCount() + containerItem.getCount()) {
|
||||
} else if (ItemUtils.isItemEqual(extraOutputSlot, containerItem, true, true) && extraOutputSlot.getMaxStackSize() < extraOutputSlot.getCount() + containerItem.getCount()) {
|
||||
extraOutputSlot.grow(1);
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +244,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isItemValidForRecipeSlot(IRecipe recipe, ItemStack stack, int slotID) {
|
||||
if (recipe == null) {
|
||||
return true;
|
||||
|
@ -328,7 +292,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
@ -356,7 +320,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
return;
|
||||
}
|
||||
IRecipe recipe = getIRecipe();
|
||||
if (recipe != null || customRecipe) {
|
||||
if (recipe != null) {
|
||||
if (progress >= maxProgress) {
|
||||
if (make(recipe)) {
|
||||
progress = 0;
|
||||
|
@ -367,10 +331,12 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
progress++;
|
||||
if (progress == 1) {
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.AUTO_CRAFTING,
|
||||
SoundCategory.BLOCKS, 0.3F, 0.8F);
|
||||
SoundCategory.BLOCKS, 0.3F, 0.8F);
|
||||
}
|
||||
useEnergy(euTick);
|
||||
}
|
||||
} else {
|
||||
progress = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -379,6 +345,15 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
}
|
||||
}
|
||||
|
||||
//Easyest way to sync back to the client
|
||||
public int getLockedInt() {
|
||||
return locked ? 1 : 0;
|
||||
}
|
||||
|
||||
public void setLockedInt(int lockedInt) {
|
||||
locked = lockedInt == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
|
@ -403,35 +378,27 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
public boolean canProvideEnergy(EnumFacing enumFacing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
if (currentRecipe != null) {
|
||||
tag.setString("currentRecipe", currentRecipe.toString());
|
||||
}
|
||||
// Disable due to performance issues
|
||||
// tag.setBoolean("customRecipe", customRecipe);
|
||||
tag.setBoolean("customRecipe", false);
|
||||
tag.setBoolean("locked", locked);
|
||||
return super.writeToNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
if (tag.hasKey("currentRecipe")) {
|
||||
currentRecipe = new ResourceLocation(tag.getString("currentRecipe"));
|
||||
if(tag.hasKey("locked")){
|
||||
locked = tag.getBoolean("locked");
|
||||
}
|
||||
// Disabled due to performance issues
|
||||
//customRecipe = tag.getBoolean("customRecipe");
|
||||
customRecipe = false;
|
||||
super.readFromNBT(tag);
|
||||
}
|
||||
|
||||
|
||||
// TileLegacyMachineBase
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
int bestSlot = findBestSlotForStack(getIRecipe(), stack);
|
||||
|
@ -441,28 +408,53 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
return super.isItemValidForSlot(index, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
if(index > 8){
|
||||
return false;
|
||||
}
|
||||
int bestSlot = findBestSlotForStack(getIRecipe(), stack);
|
||||
if (bestSlot != -1) {
|
||||
return index == bestSlot;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
if(index > 8){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//This machine doesnt have a facing
|
||||
@Override
|
||||
public EnumFacing getFacingEnum() {
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||
return new ItemStack(ModBlocks.AUTO_CRAFTING_TABLE, 1);
|
||||
}
|
||||
|
||||
|
||||
// IInventoryProvider
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(EntityPlayer player) {
|
||||
return new ContainerBuilder("autocraftingTable").player(player.inventory).inventory().hotbar()
|
||||
return new ContainerBuilder("autocraftingtable").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().tile(this)
|
||||
.slot(0, 28, 25).slot(1, 46, 25).slot(2, 64, 25)
|
||||
.slot(3, 28, 43).slot(4, 46, 43).slot(5, 64, 43)
|
||||
|
@ -470,6 +462,12 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
|
|||
.outputSlot(9, 145, 42).outputSlot(10, 145, 70).syncEnergyValue()
|
||||
.syncIntegerValue(this::getProgress, this::setProgress)
|
||||
.syncIntegerValue(this::getMaxProgress, this::setMaxProgress)
|
||||
.syncIntegerValue(this::getLockedInt, this::setLockedInt)
|
||||
.addInventory().create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSlotConfig() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"transform": "forge:default-block",
|
||||
"defaults": {
|
||||
"model": "techreborn:alarm",
|
||||
"textures": {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"transform": "forge:default-block",
|
||||
"defaults": {
|
||||
"transform": "forge:default-block",
|
||||
"model": "techreborn:lamp_incandescent",
|
||||
"textures": {
|
||||
"particle": "#lamp"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"transform": "forge:default-block",
|
||||
"defaults": {
|
||||
"transform": "forge:default-block",
|
||||
"model": "techreborn:lamp_led",
|
||||
"textures": {
|
||||
"particle": "#lamp"
|
||||
|
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 519 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 536 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 490 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 522 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 536 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 497 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 533 B |
Before Width: | Height: | Size: 690 B After Width: | Height: | Size: 552 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 416 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 818 B |
Before Width: | Height: | Size: 973 B After Width: | Height: | Size: 831 B |
Before Width: | Height: | Size: 707 B After Width: | Height: | Size: 653 B |
Before Width: | Height: | Size: 692 B After Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 700 B After Width: | Height: | Size: 662 B |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 685 B |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 829 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 924 B After Width: | Height: | Size: 867 B |
Before Width: | Height: | Size: 911 B After Width: | Height: | Size: 802 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 983 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 450 B |
Before Width: | Height: | Size: 645 B After Width: | Height: | Size: 628 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 702 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 687 B |
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 615 B |
Before Width: | Height: | Size: 732 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 612 B |
Before Width: | Height: | Size: 623 B After Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 596 B |
Before Width: | Height: | Size: 623 B After Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 918 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 899 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.1 KiB |