Merge branch '1.12' into feature/solar-panles
Conflicts: build.gradle src/main/java/techreborn/blocks/generator/BlockSolarPanel.java src/main/java/techreborn/blocks/lighting/BlockLamp.java
This commit is contained in:
commit
eab088c094
77 changed files with 948 additions and 967 deletions
108
src/main/java/techreborn/blocks/generator/BlockSolarPanel.java
Normal file
108
src/main/java/techreborn/blocks/generator/BlockSolarPanel.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue