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
|
@ -70,6 +70,7 @@ public class BlockFlare extends BlockContainer {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return (state.getValue(COLOR)).getMetadata();
|
||||
}
|
||||
|
@ -81,14 +82,17 @@ public class BlockFlare extends BlockContainer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return (state.getValue(COLOR)).getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, COLOR);
|
||||
}
|
||||
|
@ -98,6 +102,7 @@ public class BlockFlare extends BlockContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
|
|
|
@ -42,7 +42,6 @@ import prospector.shootingstar.model.ModelCompound;
|
|||
import reborncore.common.blocks.PropertyString;
|
||||
import reborncore.common.multiblock.BlockMultiblockBase;
|
||||
import reborncore.common.util.ArrayUtils;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
@ -64,11 +63,7 @@ public class BlockMachineCasing extends BlockMultiblockBase {
|
|||
setHardness(2F);
|
||||
this.setDefaultState(this.getDefaultState().withProperty(TYPE, "standard"));
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (Core.proxy.isCTMAvailable()) {
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/structure/ctm").setInvVariant("type=" + types[i]));
|
||||
} else {
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/structure").setInvVariant("type=" + types[i]));
|
||||
}
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/structure").setInvVariant("type=" + types[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,10 +94,16 @@ public class BlockMachineCasing extends BlockMultiblockBase {
|
|||
return typesList.indexOf(state.getValue(TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides heat info per casing for Industrial Blast Furnace
|
||||
* @param state Machine casing type
|
||||
* @return Integer Heat value for casing
|
||||
*/
|
||||
public int getHeatFromState(IBlockState state) {
|
||||
switch (getMetaFromState(state)) {
|
||||
case 0:
|
||||
|
|
|
@ -111,6 +111,7 @@ public class BlockMachineFrames extends BaseBlock {
|
|||
return typesList.indexOf(state.getValue(TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, TYPE);
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ public class BlockOre extends Block implements IOreNameProvider {
|
|||
return getStateFromMeta(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
String variant = state.getValue(VARIANTS);
|
||||
|
@ -230,6 +231,7 @@ public class BlockOre extends Block implements IOreNameProvider {
|
|||
return oreNamesList.indexOf(state.getValue(VARIANTS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, VARIANTS);
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ public class BlockOre2 extends Block implements IOreNameProvider {
|
|||
return oreNamesList.indexOf(state.getValue(VARIANTS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
VARIANTS = new PropertyString("type", oreNamesList);
|
||||
return new BlockStateContainer(this, VARIANTS);
|
||||
|
|
|
@ -163,6 +163,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
TYPE = new PropertyString("type", types);
|
||||
return new BlockStateContainer(this, TYPE);
|
||||
|
|
|
@ -49,6 +49,7 @@ public class BlockReinforcedGlass extends BlockGlass {
|
|||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -58,6 +59,7 @@ public class BlockReinforcedGlass extends BlockGlass {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
|
|
|
@ -77,6 +77,7 @@ public class BlockRubberLog extends Block {
|
|||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, SAP_SIDE, HAS_SAP);
|
||||
}
|
||||
|
@ -127,6 +128,7 @@ public class BlockRubberLog extends Block {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
int i = 4;
|
||||
int j = i + 1;
|
||||
|
|
|
@ -109,6 +109,7 @@ public class BlockStorage extends BaseBlock {
|
|||
return typesList.indexOf(state.getValue(TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, TYPE);
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ public class BlockStorage2 extends BaseBlock {
|
|||
return 30F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, TYPE);
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ public class BlockCable extends BlockContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||
state = state.getActualState(source, pos);
|
||||
float minX = state.getValue(WEST) ? 0.0F : 0.3125F;
|
||||
|
|
|
@ -31,7 +31,6 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import techreborn.Core;
|
||||
|
||||
public class BlockFluidTechReborn extends BlockFluidBase {
|
||||
|
||||
|
@ -41,7 +40,6 @@ public class BlockFluidTechReborn extends BlockFluidBase {
|
|||
super(fluid, material);
|
||||
setUnlocalizedName(name);
|
||||
this.name = name;
|
||||
Core.proxy.registerFluidBlockRendering(this, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -78,6 +78,7 @@ public class BlockLamp extends BaseTileBlock {
|
|||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/lighting"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
FACING = PropertyDirection.create("facing");
|
||||
ACTIVE = PropertyBool.create("active");
|
||||
|
|
|
@ -113,6 +113,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
|
|||
return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
FACING = PropertyDirection.create("facing", Facings.ALL);
|
||||
return new BlockStateContainer(this, FACING);
|
||||
|
@ -220,10 +221,12 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
|
|||
return aenumfacing[rand.nextInt(aenumfacing.length)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(EnumFacing p_apply_1_) {
|
||||
return p_apply_1_ != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<EnumFacing> iterator() {
|
||||
return Iterators.forArray(this.facings());
|
||||
}
|
||||
|
|
|
@ -30,53 +30,72 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import prospector.shootingstar.ShootingStar;
|
||||
import prospector.shootingstar.model.ModelCompound;
|
||||
import reborncore.common.BaseTileBlock;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.lesu.TileLSUStorage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Energy storage block for LESU
|
||||
*/
|
||||
public class BlockLSUStorage extends BaseTileBlock {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public BlockLSUStorage() {
|
||||
super(Material.IRON);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
if (Core.proxy.isCTMAvailable()) {
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy/ctm"));
|
||||
} else {
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy"));
|
||||
}
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||
*/
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemstack) {
|
||||
super.onBlockPlacedBy(world, pos, state, player, itemstack);
|
||||
if (world.getTileEntity(pos) instanceof TileLSUStorage) {
|
||||
((TileLSUStorage) world.getTileEntity(pos)).rebuildNetwork();
|
||||
TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
tile.rebuildNetwork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||
if (world.getTileEntity(pos) instanceof TileLSUStorage) {
|
||||
((TileLSUStorage) world.getTileEntity(pos)).removeFromNetwork();
|
||||
TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
tile.removeFromNetwork();
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets a complete list of items dropped from this block.
|
||||
*
|
||||
* @param drops add all items this block drops to this drops list
|
||||
* @param world The current world
|
||||
* @param pos Block position in world
|
||||
* @param state Current state
|
||||
* @param fortune Breakers fortune level
|
||||
*/
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
items.add(new ItemStack(this));
|
||||
return items;
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
drops.add(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +103,18 @@ public class BlockLSUStorage extends BaseTileBlock {
|
|||
return new TileLSUStorage();
|
||||
}
|
||||
|
||||
public boolean shouldConnectToBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta) {
|
||||
return block == this;
|
||||
/**
|
||||
* Determines if another block can connect to this block
|
||||
*
|
||||
* @param world The current world
|
||||
* @param pos The position of this block
|
||||
* @param facing The side the connecting block is on
|
||||
* @return True to allow another block to connect to this block
|
||||
*/
|
||||
@Override
|
||||
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing)
|
||||
{
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
return this == block;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public abstract class BlockTransformer extends BaseTileBlock {
|
|||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
FACING = PropertyDirection.create("facing", Facings.ALL);
|
||||
return new BlockStateContainer(this, FACING);
|
||||
|
@ -267,10 +268,12 @@ public abstract class BlockTransformer extends BaseTileBlock {
|
|||
return aenumfacing[rand.nextInt(aenumfacing.length)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(EnumFacing p_apply_1_) {
|
||||
return p_apply_1_ != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<EnumFacing> iterator() {
|
||||
return Iterators.forArray(this.facings());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue