Textures and block work.

This commit is contained in:
Dimmerworld 2017-10-05 21:35:23 +11:00 committed by drcrazy
parent d3ede81de4
commit c4711848ae
16 changed files with 121 additions and 107 deletions

View file

@ -25,20 +25,29 @@
package techreborn.blocks.generator.solarpanel; package techreborn.blocks.generator.solarpanel;
import java.util.List; import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; 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.Item;
import net.minecraft.item.ItemStack; 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.NonNullList;
import net.minecraft.util.math.BlockPos;
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.common.BaseTileBlock;
import reborncore.common.util.ArrayUtils;
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;
@ -48,22 +57,25 @@ import techreborn.tiles.generator.TileSolarPanel;
*/ */
public class BlockSolarPanel extends BaseTileBlock { public class BlockSolarPanel extends BaseTileBlock {
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 final PropertyEnum TYPE = PropertyEnum.create("type", EnumPanelType.class); public static final IProperty<EnumPanelType> TYPE = PropertyEnum.create("type", EnumPanelType.class);
private static final List<String> paneList = Lists.newArrayList(panes);
public BlockSolarPanel() { public BlockSolarPanel() {
super(Material.IRON); super(Material.IRON);
setCreativeTab(TechRebornCreativeTab.instance); setCreativeTab(TechRebornCreativeTab.instance);
this.setDefaultState(this.getBlockState().getBaseState().withProperty(TYPE, EnumPanelType.Basic)); this.setDefaultState(this.getBlockState().getBaseState().withProperty(TYPE, EnumPanelType.Basic));
setHardness(2.0F); setHardness(2.0F);
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/generators"));
this.setDefaultState(this.getStateFromMeta(0)); 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).setInvVariant("type=" + panes[i])); ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/generators").setInvVariant("type=" + panes[i]));
} }
} }
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(TYPE).ordinal();
}
protected BlockStateContainer createBlockState() { protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[]{TYPE}); return new BlockStateContainer(this, new IProperty[]{TYPE});
} }
@ -74,21 +86,31 @@ public class BlockSolarPanel extends BaseTileBlock {
} }
@Override @Override
public int getMetaFromState(IBlockState state) { public TileEntity createNewTileEntity(World worldIn, int meta) {
EnumPanelType type = (EnumPanelType) state.getValue(TYPE); return new TileSolarPanel();
return type.getID();
} }
@Override @Override
public TileEntity createNewTileEntity(World worldIn, int meta) { public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
return new TileSolarPanel(); 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)));
}
@Override
public int damageDropped(IBlockState state) {
return getMetaFromState(state);
} }
@Override @Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (EnumPanelType panelType : EnumPanelType.values()) { for (EnumPanelType panelType : EnumPanelType.values()) {
list.add(new ItemStack(this, 1, panelType.ordinal())); list.add(new ItemStack(this, 1, panelType.ordinal()));
System.out.println((new ItemStack(this, 1, panelType.ordinal())) + "daad");
} }
} }
} }

View file

@ -24,6 +24,7 @@
package techreborn.tiles.generator; package techreborn.tiles.generator;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -32,6 +33,7 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.registration.impl.ConfigRegistry;
import techreborn.blocks.generator.solarpanel.BlockSolarPanel; import techreborn.blocks.generator.solarpanel.BlockSolarPanel;
import techreborn.blocks.generator.solarpanel.EnumPanelType;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
@ -44,59 +46,50 @@ import java.util.List;
@RebornRegistry(modID = ModInfo.MOD_ID) @RebornRegistry(modID = ModInfo.MOD_ID)
public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
@ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelMaxOutput", comment = "Solar Panel Max Output (Value in EU)") // @ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelMaxOutput", comment = "Solar Panel Max Output (Value in EU)")
public static int maxOutput = 32; // public static int maxOutput = 32;
@ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelMaxEnergy", comment = "Solar Panel Max Energy (Value in EU)") // @ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelMaxEnergy", comment = "Solar Panel Max Energy (Value in EU)")
public static int maxEnergy = 1000; // public static int maxEnergy = 1000;
@ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelEnergyPerTick", comment = "Solar Panel Energy Per Tick (Value in EU)") // @ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelEnergyPerTick", comment = "Solar Panel Energy Per Tick (Value in EU)")
public static int energyPerTick = 1; // public static int energyPerTick = 1;
boolean shouldMakePower = false; boolean shouldMakePower = false;
boolean lastTickSate = false; boolean lastTickSate = false;
int powerToAdd; int powerToAdd;
public TileSolarPanel() { public TileSolarPanel() {
super(); super();
IBlockState panelType = world.getBlockState(pos);
System.out.println(panelType + " Dimmer");
} }
@Override @Override
public void update() { public void update() {
super.update(); // super.update();
if (!this.world.isRemote) { // if (!this.world.isRemote) {
if (this.world.getTotalWorldTime() % 60 == 0) { // if (this.world.getTotalWorldTime() % 60 == 0) {
this.shouldMakePower = this.isSunOut(); // this.shouldMakePower = this.isSunOut();
//
} // }
if (this.shouldMakePower) { // if (this.shouldMakePower) {
this.powerToAdd = energyPerTick; // this.powerToAdd = energyPerTick;
this.addEnergy(this.powerToAdd); // this.addEnergy(this.powerToAdd);
} else { // } else {
this.powerToAdd = 0; // this.powerToAdd = 0;
} // }
//
} // }
} }
@Override
public void addInfo(final List<String> info, final boolean isRealTile) {
super.addInfo(info, isRealTile);
if (isRealTile) {
// FIXME: 25/02/2016
// info.add(TextFormatting.LIGHT_PURPLE + "Power gen/tick " +
// TextFormatting.GREEN + PowerSystem.getLocaliszedPower(
// powerToAdd)) ;
}
}
public boolean isSunOut() { // public boolean isSunOut() {
return this.world.canBlockSeeSky(this.pos.up()) && !this.world.isRaining() && !this.world.isThundering() // return this.world.canBlockSeeSky(this.pos.up()) && !this.world.isRaining() && !this.world.isThundering()
&& this.world.isDaytime(); // && this.world.isDaytime();
} // }
@Override @Override
public double getBaseMaxPower() { public double getBaseMaxPower() {
return maxEnergy; return 5;
} }
@Override @Override
@ -111,14 +104,16 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
@Override @Override
public double getBaseMaxOutput() { public double getBaseMaxOutput() {
return maxOutput; return 200;
} }
private EnumPanelType getPanelType() {
return world.getBlockState(pos).getValue(BlockSolarPanel.TYPE);
}
@Override @Override
public double getBaseMaxInput() { public double getBaseMaxInput() {
return 0; return 0;
} }
@Override @Override
public ItemStack getToolDrop(final EntityPlayer p0) { public ItemStack getToolDrop(final EntityPlayer p0) {
return new ItemStack(ModBlocks.SOLAR_PANEL); return new ItemStack(ModBlocks.SOLAR_PANEL);

View file

@ -1,60 +1,57 @@
{ {
"forge_marker": 1, "forge_marker": 1,
"defaults": { "defaults": {
"textures": {}, "textures": {},
"transform": "forge:default-block", "transform": "forge:default-block",
"model": "cube_bottom_top" "model": "cube_bottom_top"
}, },
"variants": { "variants": {
"inventory": { "inventory": {
"transform": "forge:default-block", "transform": "forge:default-block",
"model": "cube_bottom_top", "model": "orientable",
"textures": { "textures": {}
"side": "techreborn:blocks/machines/generators/solar_panel_side_off" },
} "type": {
}, "basic": {
"type": { "textures": {
"basic": { "particle": "techreborn:blocks/machines/generators/panels/basicsolar_panel_side",
"textures": { "top": "techreborn:blocks/machines/generators/panels/basicsolar_panel_top",
"particle": "techreborn:blocks/machines/generators/solar_panel_side_off", "down": "techreborn:blocks/machines/generators/generator_bottom",
"top": "techreborn:blocks/machines/generators/solar_panel_top", "side": "techreborn:blocks/machines/generators/panels/basicsolar_panel_side"
"down": "techreborn:blocks/machines/generators/generator_bottom", }
"side": "techreborn:blocks/machines/generators/solar_panel_side_off" },
} "hybrid": {
}, "textures": {
"hybrid": { "particle": "techreborn:blocks/machines/generators/panels/hybridsolar_panel_side",
"textures": { "top": "techreborn:blocks/machines/generators/panels/hybridsolar_panel_top",
"particle": "techreborn:blocks/machines/generators/solar_panel_side_off", "down": "techreborn:blocks/machines/generators/generator_bottom",
"top": "techreborn:blocks/machines/generators/solar_panel_top", "side": "techreborn:blocks/machines/generators/panels/hybridsolar_panel_side"
"down": "techreborn:blocks/machines/generators/generator_bottom", }
"side": "techreborn:blocks/machines/generators/solar_panel_side_off" },
} "advanced": {
}, "textures": {
"advanced": { "particle": "techreborn:blocks/machines/generators/panels/advancedsolar_panel_side",
"textures": { "top": "techreborn:blocks/machines/generators/panels/advancedsolar_panel_top",
"particle": "techreborn:blocks/machines/generators/solar_panel_side_off", "down": "techreborn:blocks/machines/generators/generator_bottom",
"top": "techreborn:blocks/machines/generators/solar_panel_top", "side": "techreborn:blocks/machines/generators/panels/advancedsolar_panel_side"
"down": "techreborn:blocks/machines/generators/generator_bottom", }
"side": "techreborn:blocks/machines/generators/solar_panel_side_off" },
} "ultimate": {
}, "textures": {
"ultimate": { "particle": "techreborn:blocks/machines/generators/panels/ultimatesolar_panel_side",
"textures": { "top": "techreborn:blocks/machines/generators/panels/ultimatesolar_panel_top",
"particle": "techreborn:blocks/machines/generators/solar_panel_side_off", "down": "techreborn:blocks/machines/generators/generator_bottom",
"top": "techreborn:blocks/machines/generators/solar_panel_top", "side": "techreborn:blocks/machines/generators/panels/ultimatesolar_panel_side"
"down": "techreborn:blocks/machines/generators/generator_bottom", }
"side": "techreborn:blocks/machines/generators/solar_panel_side_off" },
} "quantum": {
}, "textures": {
"quantum": { "particle": "techreborn:blocks/machines/generators/panels/quantumsolar_panel_side",
"textures": { "top": "techreborn:blocks/machines/generators/panels/quantumsolar_panel_top",
"particle": "techreborn:blocks/machines/generators/solar_panel_side_off", "down": "techreborn:blocks/machines/generators/generator_bottom",
"top": "techreborn:blocks/machines/generators/solar_panel_top", "side": "techreborn:blocks/machines/generators/panels/quantumsolar_panel_side"
"down": "techreborn:blocks/machines/generators/generator_bottom", }
"side": "techreborn:blocks/machines/generators/solar_panel_side_off" }
} }
} }
}
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB