Some work on solar panels flattening
This commit is contained in:
parent
0918bceb23
commit
4245decc3c
5 changed files with 33 additions and 212 deletions
|
@ -1,97 +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.blocks.generator;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import reborncore.api.ToolManager;
|
|
||||||
import reborncore.client.models.ModelCompound;
|
|
||||||
import reborncore.client.models.RebornModelRegistry;
|
|
||||||
import reborncore.common.BaseTileBlock;
|
|
||||||
import reborncore.common.RebornCoreConfig;
|
|
||||||
import reborncore.common.blocks.BlockWrenchEventHandler;
|
|
||||||
import reborncore.common.items.WrenchHelper;
|
|
||||||
import techreborn.TechReborn;
|
|
||||||
import techreborn.init.ModBlocks;
|
|
||||||
import techreborn.tiles.generator.TileCreativeSolarPanel;
|
|
||||||
import techreborn.utils.TechRebornCreativeTab;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by modmuss50 on 25/02/2016.
|
|
||||||
*/
|
|
||||||
public class BlockCreativeSolarPanel extends BaseTileBlock {
|
|
||||||
|
|
||||||
public BlockCreativeSolarPanel() {
|
|
||||||
super(Material.IRON);
|
|
||||||
setCreativeTab(TechRebornCreativeTab.instance);
|
|
||||||
setHardness(2.0F);
|
|
||||||
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/generators"));
|
|
||||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand,
|
|
||||||
EnumFacing side, float hitX, float hitY, float hitZ) {
|
|
||||||
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
|
|
||||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
|
||||||
|
|
||||||
// We extended BaseTileBlock. Thus we should always have tile entity. I hope.
|
|
||||||
if (tileEntity == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
|
||||||
if (WrenchHelper.handleWrench(stack, worldIn, pos, playerIn, side)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
|
||||||
if (RebornCoreConfig.wrenchRequired) {
|
|
||||||
drops.add(new ItemStack(ModBlocks.MACHINE_BLOCK_ADVANCED));
|
|
||||||
} else {
|
|
||||||
super.getDrops(drops, world, pos, state, fortune);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
|
||||||
return new TileCreativeSolarPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,95 +24,30 @@
|
||||||
|
|
||||||
package techreborn.blocks.generator.solarpanel;
|
package techreborn.blocks.generator.solarpanel;
|
||||||
|
|
||||||
import net.minecraft.block.properties.IProperty;
|
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.api.tile.IMachineGuiHandler;
|
import reborncore.api.tile.IMachineGuiHandler;
|
||||||
import reborncore.client.models.ModelCompound;
|
import reborncore.client.models.ModelCompound;
|
||||||
import reborncore.client.models.RebornModelRegistry;
|
import reborncore.client.models.RebornModelRegistry;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.tiles.generator.TileSolarPanel;
|
|
||||||
import techreborn.utils.TechRebornCreativeTab;
|
import techreborn.utils.TechRebornCreativeTab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 25/02/2016.
|
* Created by modmuss50 on 25/02/2016.
|
||||||
*/
|
*/
|
||||||
public class BlockSolarPanel extends BlockMachineBase {
|
public class BlockSolarPanel extends BlockMachineBase {
|
||||||
public static final String[] panes = new String[] {
|
|
||||||
"basic", "hybrid", "advanced", "ultimate", "quantum"};
|
|
||||||
public static PropertyBool ACTIVE = PropertyBool.create("active");
|
|
||||||
public static final IProperty<EnumPanelType> TYPE = PropertyEnum.create("type", EnumPanelType.class);
|
|
||||||
|
|
||||||
public BlockSolarPanel() {
|
public BlockSolarPanel() {
|
||||||
super(true);
|
super();
|
||||||
setCreativeTab(TechRebornCreativeTab.instance);
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
this.setDefaultState(this.getBlockState().getBaseState().withProperty(ACTIVE, false).withProperty(TYPE, EnumPanelType.Basic));
|
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/generators"));
|
||||||
for (int i = 0; i < panes.length; i++) {
|
|
||||||
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, i, "machines/generators").setInvVariant("active=false,type=" + panes[i]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(IBlockState state) {
|
public TileEntity createNewTileEntity(final World world, final int meta) {
|
||||||
int active = state.getValue(ACTIVE) ? EnumPanelType.values().length : 0;
|
// TODO: FIx me
|
||||||
return state.getValue(TYPE).ordinal() + active;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, ACTIVE, TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState getStateFromMeta(int meta) {
|
|
||||||
boolean active = false;
|
|
||||||
if(meta >= EnumPanelType.values().length){
|
|
||||||
active = true;
|
|
||||||
meta -= EnumPanelType.values().length;
|
|
||||||
}
|
|
||||||
return getDefaultState().withProperty(ACTIVE, active).withProperty(TYPE, EnumPanelType.values()[meta]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
|
||||||
return new TileSolarPanel(getStateFromMeta(meta).getValue(TYPE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
|
|
||||||
return getStateFromMeta(placer.getHeldItem(hand).getItemDamage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
|
||||||
//return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
|
|
||||||
return new ItemStack(Item.getItemFromBlock(this), 1, world.getBlockState(pos).getValue(TYPE).ordinal());
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public int damageDropped(IBlockState state) {
|
|
||||||
return state.getValue(TYPE).ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
||||||
for (EnumPanelType panelType : EnumPanelType.values()) {
|
|
||||||
list.add(new ItemStack(this, 1, panelType.ordinal()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,8 @@ public enum EnumPanelType implements IStringSerializable {
|
||||||
Hybrid("hybrid", EnumPowerTier.LOW),
|
Hybrid("hybrid", EnumPowerTier.LOW),
|
||||||
Advanced("advanced", EnumPowerTier.MEDIUM),
|
Advanced("advanced", EnumPowerTier.MEDIUM),
|
||||||
Ultimate("ultimate", EnumPowerTier.HIGH),
|
Ultimate("ultimate", EnumPowerTier.HIGH),
|
||||||
Quantum("quantum", EnumPowerTier.EXTREME);
|
Quantum("quantum", EnumPowerTier.EXTREME),
|
||||||
|
CREATIVE("creative", EnumPowerTier.EXTREME);
|
||||||
|
|
||||||
private String friendlyName;
|
private String friendlyName;
|
||||||
// Generation of EU during Day
|
// Generation of EU during Day
|
||||||
|
@ -48,6 +49,7 @@ public enum EnumPanelType implements IStringSerializable {
|
||||||
EnumPanelType(String friendlyName, EnumPowerTier tier) {
|
EnumPanelType(String friendlyName, EnumPowerTier tier) {
|
||||||
this.friendlyName = friendlyName;
|
this.friendlyName = friendlyName;
|
||||||
this.powerTier = tier;
|
this.powerTier = tier;
|
||||||
|
// TODO: Fix me
|
||||||
switch (friendlyName) {
|
switch (friendlyName) {
|
||||||
case "basic":
|
case "basic":
|
||||||
this.generationRateD = ConfigTechReborn.basicGenerationRateD;
|
this.generationRateD = ConfigTechReborn.basicGenerationRateD;
|
||||||
|
|
|
@ -99,7 +99,6 @@ public class ModBlocks {
|
||||||
public static Block VACUUM_FREEZER;
|
public static Block VACUUM_FREEZER;
|
||||||
|
|
||||||
// Machines - generators
|
// Machines - generators
|
||||||
public static Block CREATIVE_SOLAR_PANEL;
|
|
||||||
public static Block DIESEL_GENERATOR;
|
public static Block DIESEL_GENERATOR;
|
||||||
public static Block DRAGON_EGG_SYPHON;
|
public static Block DRAGON_EGG_SYPHON;
|
||||||
public static Block FUSION_COIL;
|
public static Block FUSION_COIL;
|
||||||
|
@ -108,7 +107,13 @@ public class ModBlocks {
|
||||||
public static Block LIGHTNING_ROD;
|
public static Block LIGHTNING_ROD;
|
||||||
public static Block PLASMA_GENERATOR;
|
public static Block PLASMA_GENERATOR;
|
||||||
public static Block SEMI_FLUID_GENERATOR;
|
public static Block SEMI_FLUID_GENERATOR;
|
||||||
public static Block SOLAR_PANEL;
|
public static Block SOLAR_PANEL_BASIC;
|
||||||
|
public static Block SOLAR_PANEL_ADVANCED;
|
||||||
|
public static Block SOLAR_PANEL_INDUSTRIAL;
|
||||||
|
public static Block SOLAR_PANEL_ULTIMATE;
|
||||||
|
public static Block SOLAR_PANEL_QUANTUM;
|
||||||
|
public static Block SOLAR_PANEL_CREATIVE;
|
||||||
|
|
||||||
public static Block SOLID_FUEL_GENEREATOR;
|
public static Block SOLID_FUEL_GENEREATOR;
|
||||||
public static Block THERMAL_GENERATOR;
|
public static Block THERMAL_GENERATOR;
|
||||||
public static Block WATER_MILL;
|
public static Block WATER_MILL;
|
||||||
|
@ -257,9 +262,6 @@ public class ModBlocks {
|
||||||
registerBlock(VACUUM_FREEZER, "vacuum_freezer");
|
registerBlock(VACUUM_FREEZER, "vacuum_freezer");
|
||||||
|
|
||||||
// Machines - generators
|
// Machines - generators
|
||||||
CREATIVE_SOLAR_PANEL = new BlockCreativeSolarPanel();
|
|
||||||
registerBlock(CREATIVE_SOLAR_PANEL, "creative_solar_panel");
|
|
||||||
|
|
||||||
DIESEL_GENERATOR = new BlockDieselGenerator();
|
DIESEL_GENERATOR = new BlockDieselGenerator();
|
||||||
registerBlock(DIESEL_GENERATOR, "diesel_generator");
|
registerBlock(DIESEL_GENERATOR, "diesel_generator");
|
||||||
|
|
||||||
|
@ -284,8 +286,23 @@ public class ModBlocks {
|
||||||
SEMI_FLUID_GENERATOR = new BlockSemiFluidGenerator();
|
SEMI_FLUID_GENERATOR = new BlockSemiFluidGenerator();
|
||||||
registerBlock(SEMI_FLUID_GENERATOR, "semi_fluid_generator");
|
registerBlock(SEMI_FLUID_GENERATOR, "semi_fluid_generator");
|
||||||
|
|
||||||
SOLAR_PANEL = new BlockSolarPanel();
|
SOLAR_PANEL_BASIC = new BlockSolarPanel();
|
||||||
registerBlock(SOLAR_PANEL, ItemBlockSolarPanel.class, "solar_panel");
|
registerBlock(SOLAR_PANEL_BASIC, "solar_panel_basic");
|
||||||
|
|
||||||
|
SOLAR_PANEL_ADVANCED = new BlockSolarPanel();
|
||||||
|
registerBlock(SOLAR_PANEL_ADVANCED, "solar_panel_advanced");
|
||||||
|
|
||||||
|
SOLAR_PANEL_INDUSTRIAL = new BlockSolarPanel();
|
||||||
|
registerBlock(SOLAR_PANEL_INDUSTRIAL, "solar_panel_industrial");
|
||||||
|
|
||||||
|
SOLAR_PANEL_ULTIMATE = new BlockSolarPanel();
|
||||||
|
registerBlock(SOLAR_PANEL_ULTIMATE, "solar_panel_ultimate");
|
||||||
|
|
||||||
|
SOLAR_PANEL_QUANTUM = new BlockSolarPanel();
|
||||||
|
registerBlock(SOLAR_PANEL_QUANTUM, "solar_panel_quantum");
|
||||||
|
|
||||||
|
SOLAR_PANEL_CREATIVE = new BlockSolarPanel();
|
||||||
|
registerBlock(SOLAR_PANEL_CREATIVE, "solar_panel_creative");
|
||||||
|
|
||||||
SOLID_FUEL_GENEREATOR = new BlockSolidFuelGenerator();
|
SOLID_FUEL_GENEREATOR = new BlockSolidFuelGenerator();
|
||||||
registerBlock(SOLID_FUEL_GENEREATOR, "solid_fuel_generator");
|
registerBlock(SOLID_FUEL_GENEREATOR, "solid_fuel_generator");
|
||||||
|
|
|
@ -1,36 +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.itemblocks;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import reborncore.common.itemblock.ItemBlockBase;
|
|
||||||
import techreborn.blocks.generator.solarpanel.BlockSolarPanel;
|
|
||||||
import techreborn.init.ModBlocks;
|
|
||||||
|
|
||||||
public class ItemBlockSolarPanel extends ItemBlockBase {
|
|
||||||
public ItemBlockSolarPanel(Block block){
|
|
||||||
super(ModBlocks.SOLAR_PANEL, ModBlocks.SOLAR_PANEL, BlockSolarPanel.panes);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue