Made solar panel wrenchable
This commit is contained in:
parent
6202b46cf7
commit
df24adb936
3 changed files with 10 additions and 115 deletions
|
@ -1,108 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 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.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import prospector.shootingstar.ShootingStar;
|
|
||||||
import prospector.shootingstar.model.ModelCompound;
|
|
||||||
import reborncore.common.BaseTileBlock;
|
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
|
||||||
import techreborn.lib.ModInfo;
|
|
||||||
import techreborn.tiles.generator.TileSolarPanel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by modmuss50 on 25/02/2016.
|
|
||||||
*/
|
|
||||||
public class BlockSolarPanel extends BaseTileBlock {
|
|
||||||
|
|
||||||
public static PropertyBool ACTIVE = PropertyBool.create("active");
|
|
||||||
|
|
||||||
public BlockSolarPanel() {
|
|
||||||
super(Material.IRON);
|
|
||||||
setCreativeTab(TechRebornCreativeTab.instance);
|
|
||||||
this.setDefaultState(this.getDefaultState().withProperty(ACTIVE, false));
|
|
||||||
setHardness(2.0F);
|
|
||||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/generators"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
ACTIVE = PropertyBool.create("active");
|
|
||||||
return new BlockStateContainer(this, ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState getStateFromMeta(int meta) {
|
|
||||||
return getDefaultState().withProperty(ACTIVE, meta != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(IBlockState state) {
|
|
||||||
return state.getValue(ACTIVE) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
|
||||||
return new TileSolarPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block neighborBlock, BlockPos p_189540_5_) {
|
|
||||||
if (worldIn.canBlockSeeSky(pos.up()) && !worldIn.isRaining() && !worldIn.isThundering()
|
|
||||||
&& worldIn.isDaytime()) {
|
|
||||||
worldIn.setBlockState(pos,
|
|
||||||
worldIn.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, true));
|
|
||||||
} else {
|
|
||||||
|
|
||||||
worldIn.setBlockState(pos,
|
|
||||||
worldIn.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY,
|
|
||||||
float hitZ, int meta, EntityLivingBase placer) {
|
|
||||||
if (!worldIn.isRemote) {
|
|
||||||
if (worldIn.canBlockSeeSky(pos.up()) && !worldIn.isRaining() && !worldIn.isThundering() && worldIn.isDaytime()) {
|
|
||||||
return this.getDefaultState().withProperty(ACTIVE, true);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return this.getDefaultState().withProperty(ACTIVE, false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return this.getDefaultState().withProperty(ACTIVE, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
package techreborn.blocks.generator.solarpanel;
|
package techreborn.blocks.generator.solarpanel;
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
@ -44,7 +43,8 @@ import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import prospector.shootingstar.ShootingStar;
|
import prospector.shootingstar.ShootingStar;
|
||||||
import prospector.shootingstar.model.ModelCompound;
|
import prospector.shootingstar.model.ModelCompound;
|
||||||
import reborncore.common.BaseTileBlock;
|
import reborncore.api.tile.IMachineGuiHandler;
|
||||||
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
import techreborn.tiles.generator.TileSolarPanel;
|
import techreborn.tiles.generator.TileSolarPanel;
|
||||||
|
@ -52,18 +52,16 @@ import techreborn.tiles.generator.TileSolarPanel;
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 25/02/2016.
|
* Created by modmuss50 on 25/02/2016.
|
||||||
*/
|
*/
|
||||||
public class BlockSolarPanel extends BaseTileBlock {
|
public class BlockSolarPanel extends BlockMachineBase {
|
||||||
public static final String[] panes = new String[] {
|
public static final String[] panes = new String[] {
|
||||||
"basic", "hybrid", "advanced", "ultimate", "quantum"};
|
"basic", "hybrid", "advanced", "ultimate", "quantum"};
|
||||||
public static PropertyBool ACTIVE = PropertyBool.create("active");
|
public static PropertyBool ACTIVE = PropertyBool.create("active");
|
||||||
public static final IProperty<EnumPanelType> TYPE = PropertyEnum.create("type", EnumPanelType.class);
|
public static final IProperty<EnumPanelType> TYPE = PropertyEnum.create("type", EnumPanelType.class);
|
||||||
|
|
||||||
public BlockSolarPanel() {
|
public BlockSolarPanel() {
|
||||||
super(Material.IRON);
|
super(true);
|
||||||
setCreativeTab(TechRebornCreativeTab.instance);
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
this.setDefaultState(this.getBlockState().getBaseState().withProperty(ACTIVE, false).withProperty(TYPE, EnumPanelType.Basic));
|
this.setDefaultState(this.getBlockState().getBaseState().withProperty(ACTIVE, false).withProperty(TYPE, EnumPanelType.Basic));
|
||||||
setHardness(2.0F);
|
|
||||||
//this.setDefaultState(this.getStateFromMeta(0));
|
|
||||||
for (int i = 0; i < panes.length; i++) {
|
for (int i = 0; i < panes.length; i++) {
|
||||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/generators").setInvVariant("active=false,type=" + panes[i]));
|
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/generators").setInvVariant("active=false,type=" + panes[i]));
|
||||||
}
|
}
|
||||||
|
@ -116,4 +114,9 @@ public class BlockSolarPanel extends BaseTileBlock {
|
||||||
list.add(new ItemStack(this, 1, panelType.ordinal()));
|
list.add(new ItemStack(this, 1, panelType.ordinal()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMachineGuiHandler getGui() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer p0) {
|
public ItemStack getToolDrop(final EntityPlayer p0) {
|
||||||
return new ItemStack(ModBlocks.SOLAR_PANEL, 1, world.getBlockState(pos).getBlock().getMetaFromState(world.getBlockState(pos)));
|
return new ItemStack(ModBlocks.SOLAR_PANEL, 1, this.panel.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue