Fixed typos for tier1 tiles folder. New abstract TR machine class

This commit is contained in:
drcrazy 2018-04-02 16:18:48 +03:00
parent f5b0670d84
commit 80e36f0427
27 changed files with 177 additions and 119 deletions

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.iron_machines;
package techreborn.blocks.tier0;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
@ -37,7 +37,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileIronAlloyFurnace;
import techreborn.tiles.tier0.TileIronAlloyFurnace;
import java.util.ArrayList;
import java.util.List;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.iron_machines;
package techreborn.blocks.tier0;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
@ -41,7 +41,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileIronFurnace;
import techreborn.tiles.tier0.TileIronFurnace;
import java.util.ArrayList;
import java.util.List;
@ -55,23 +55,6 @@ public class BlockIronFurnace extends BlockMachineBase {
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier0_machines"));
}
@Override
public TileEntity createNewTileEntity(final World world, final int p_149915_2_) {
return new TileIronFurnace();
}
@Override
public IMachineGuiHandler getGui() {
return EGui.IRON_FURNACE;
}
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final List<ItemStack> items = new ArrayList<>();
items.add(new ItemStack(this));
return items;
}
@SideOnly(Side.CLIENT)
@SuppressWarnings("incomplete-switch")
public void randomDisplayTick(final World worldIn, final BlockPos pos, final IBlockState state, final Random rand) {
@ -106,4 +89,22 @@ public class BlockIronFurnace extends BlockMachineBase {
}
}
}
// BlockMachineBase
@Override
public TileEntity createNewTileEntity(final World world, final int p_149915_2_) {
return new TileIronFurnace();
}
@Override
public IMachineGuiHandler getGui() {
return EGui.IRON_FURNACE;
}
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final List<ItemStack> items = new ArrayList<>();
items.add(new ItemStack(this));
return items;
}
}

View file

@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.teir1.TileAlloySmelter;
import techreborn.tiles.tier1.TileAlloySmelter;
public class BlockAlloySmelter extends BlockMachineBase {

View file

@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.teir1.TileCompressor;
import techreborn.tiles.tier1.TileCompressor;
public class BlockCompressor extends BlockMachineBase {

View file

@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.teir1.TileElectricFurnace;
import techreborn.tiles.tier1.TileElectricFurnace;
public class BlockElectricFurnace extends BlockMachineBase {

View file

@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.teir1.TileExtractor;
import techreborn.tiles.tier1.TileExtractor;
public class BlockExtractor extends BlockMachineBase {

View file

@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.teir1.TileGrinder;
import techreborn.tiles.tier1.TileGrinder;
public class BlockGrinder extends BlockMachineBase {

View file

@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.teir1.TileRecycler;
import techreborn.tiles.tier1.TileRecycler;
public class BlockRecycler extends BlockMachineBase {

View file

@ -43,7 +43,8 @@ import techreborn.tiles.storage.TileAdjustableSU;
import techreborn.tiles.storage.TileHighVoltageSU;
import techreborn.tiles.storage.TileLowVoltageSU;
import techreborn.tiles.storage.TileMediumVoltageSU;
import techreborn.tiles.teir1.*;
import techreborn.tiles.tier0.*;
import techreborn.tiles.tier1.*;
public class GuiHandler implements IGuiHandler {

View file

@ -29,7 +29,7 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import techreborn.tiles.TileIronAlloyFurnace;
import techreborn.tiles.tier0.TileIronAlloyFurnace;
public class GuiAlloyFurnace extends GuiContainer {

View file

@ -25,7 +25,7 @@
package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import techreborn.tiles.teir1.TileAlloySmelter;
import techreborn.tiles.tier1.TileAlloySmelter;
public class GuiAlloySmelter extends GuiBase {

View file

@ -25,7 +25,7 @@
package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import techreborn.tiles.teir1.TileCompressor;
import techreborn.tiles.tier1.TileCompressor;
public class GuiCompressor extends GuiBase {

View file

@ -25,7 +25,7 @@
package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import techreborn.tiles.teir1.TileElectricFurnace;
import techreborn.tiles.tier1.TileElectricFurnace;
public class GuiElectricFurnace extends GuiBase {

View file

@ -25,7 +25,7 @@
package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import techreborn.tiles.teir1.TileExtractor;
import techreborn.tiles.tier1.TileExtractor;
public class GuiExtractor extends GuiBase {

View file

@ -25,7 +25,7 @@
package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import techreborn.tiles.teir1.TileGrinder;
import techreborn.tiles.tier1.TileGrinder;
public class GuiGrinder extends GuiBase {

View file

@ -29,7 +29,7 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import techreborn.tiles.TileIronFurnace;
import techreborn.tiles.tier0.TileIronFurnace;
public class GuiIronFurnace extends GuiContainer {

View file

@ -25,7 +25,7 @@
package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import techreborn.tiles.teir1.TileRecycler;
import techreborn.tiles.tier1.TileRecycler;
public class GuiRecycler extends GuiBase {

View file

@ -41,11 +41,10 @@ import techreborn.blocks.advanced_machine.*;
import techreborn.blocks.cable.BlockCable;
import techreborn.blocks.generator.*;
import techreborn.blocks.generator.solarpanel.BlockSolarPanel;
import techreborn.blocks.iron_machines.BlockIronAlloyFurnace;
import techreborn.blocks.iron_machines.BlockIronFurnace;
import techreborn.blocks.lighting.BlockLamp;
import techreborn.blocks.machine.*;
import techreborn.blocks.storage.*;
import techreborn.blocks.tier0.*;
import techreborn.blocks.tier1.*;
import techreborn.blocks.transformers.BlockHVTransformer;
import techreborn.blocks.transformers.BlockLVTransformer;
@ -65,7 +64,8 @@ import techreborn.tiles.storage.TileAdjustableSU;
import techreborn.tiles.storage.TileHighVoltageSU;
import techreborn.tiles.storage.TileLowVoltageSU;
import techreborn.tiles.storage.TileMediumVoltageSU;
import techreborn.tiles.teir1.*;
import techreborn.tiles.tier0.*;
import techreborn.tiles.tier1.*;
import techreborn.tiles.transformers.TileHVTransformer;
import techreborn.tiles.transformers.TileLVTransformer;
import techreborn.tiles.transformers.TileMVTransformer;

View file

@ -0,0 +1,123 @@
/*
* 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.tiles;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Inventory;
/**
* @author drcrazy
*
*/
public abstract class TileGenericMachine extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider{
public String name;
public int maxInput;
public int maxEnergy;
public Block toolDrop;
public int energySlot;
public Inventory inventory;
public RecipeCrafter crafter;
public TileGenericMachine(String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) {
this.name = "Tile" + name;
this.maxInput = maxInput;
this.maxEnergy = maxEnergy;
this.toolDrop = toolDrop;
this.energySlot = energySlot;
}
public int getProgressScaled(final int scale) {
if (this.crafter != null && this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
// TilePowerAcceptor
@Override
public void update() {
if (!this.world.isRemote) {
super.update();
this.charge(energySlot);
}
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
// IToolDrop
@Override
public ItemStack getToolDrop(EntityPlayer p0) {
return new ItemStack(toolDrop, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return inventory;
}
// IRecipeCrafterProvider
@Override
public RecipeCrafter getRecipeCrafter() {
return crafter;
}
}

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.tiles;
package techreborn.tiles.tier0;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.tiles;
package techreborn.tiles.tier0;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.tiles.teir1;
package techreborn.tiles.tier1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

View file

@ -22,15 +22,9 @@
* SOFTWARE.
*/
package techreborn.tiles.teir1;
package techreborn.tiles.tier1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.Inventory;
@ -39,78 +33,23 @@ import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.tiles.TileGenericMachine;
public class TileCompressor extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider {
public class TileCompressor extends TileGenericMachine implements IContainerProvider {
@ConfigRegistry(config = "machines", category = "compressor", key = "CompressorInput", comment = "Compressor Max Input (Value in EU)")
public static int maxInput = 32;
@ConfigRegistry(config = "machines", category = "compressor", key = "CompressorMaxEnergy", comment = "Compressor Max Energy (Value in EU)")
public static int maxEnergy = 1000;
public Inventory inventory = new Inventory(3, "TileCompressor", 64, this);
public RecipeCrafter crafter;
public TileCompressor() {
super();
super("Compressor", maxInput, maxEnergy, ModBlocks.COMPRESSOR, 2);
final int[] inputs = new int[] { 0 };
final int[] outputs = new int[] { 1 };
this.inventory = new Inventory(3, "TileCompressor", 64, this);
this.crafter = new RecipeCrafter(Reference.COMPRESSOR_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
}
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
// TilePowerAcceptor
@Override
public void update() {
if (!this.world.isRemote) {
super.update();
this.charge(2);
}
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.COMPRESSOR, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
@ -118,10 +57,4 @@ public class TileCompressor extends TilePowerAcceptor
.tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
.syncCrafterValue().addInventory().create(this);
}
// IRecipeCrafterProvider
@Override
public RecipeCrafter getRecipeCrafter() {
return this.crafter;
}
}

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.tiles.teir1;
package techreborn.tiles.tier1;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.tiles.teir1;
package techreborn.tiles.tier1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.tiles.teir1;
package techreborn.tiles.tier1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.tiles.teir1;
package techreborn.tiles.tier1;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;