Skip to content

Commit

Permalink
update to B0.9
Browse files Browse the repository at this point in the history
Fix computer bug.And add many new things.
  • Loading branch information
DawningW committed Jun 26, 2016
1 parent 3a65660 commit 649bef2
Show file tree
Hide file tree
Showing 39 changed files with 497 additions and 50 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "B0.8"
version = "B0.9"
group= "WdawningStudio" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "wcscience"

Expand Down
81 changes: 44 additions & 37 deletions src/main/java/WdawningStudio/DawnW/science/block/BlockComputer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
Expand All @@ -28,7 +31,7 @@ public static class SimpleComputer extends BlockComputer
{
public SimpleComputer()
{
super(Material.glass);
super(Material.iron);
this.setUnlocalizedName("simpleComputer");
this.setHarvestLevel("ItemPickaxe", 1);
this.setHardness(3.0f);
Expand All @@ -44,7 +47,7 @@ public static class HighComputer extends BlockComputer
{
public HighComputer()
{
super(Material.glass);
super(Material.iron);
this.setUnlocalizedName("highComputer");
this.setHarvestLevel("ItemPickaxe", 2);
this.setHardness(3.0f);
Expand All @@ -60,7 +63,7 @@ public static class ProComputer extends BlockComputer
{
public ProComputer()
{
super(Material.glass);
super(Material.iron);
this.setUnlocalizedName("proComputer");
this.setHarvestLevel("ItemPickaxe", 2);
this.setHardness(3.0f);
Expand All @@ -76,7 +79,7 @@ public static class SuperComputer extends BlockComputer
{
public SuperComputer()
{
super(Material.glass);
super(Material.iron);
this.setUnlocalizedName("superComputer");
this.setHarvestLevel("ItemPickaxe", 2);
this.setHardness(3.0f);
Expand All @@ -87,40 +90,44 @@ public SuperComputer()
}
}

/*
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
this.setDefaultFacing(worldIn, pos, state);
}
@Override
public boolean isOpaqueCube()
{
return false;
}

private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
if (!worldIn.isRemote)
{
Block block = worldIn.getBlockState(pos.north()).getBlock();
Block block1 = worldIn.getBlockState(pos.south()).getBlock();
Block block2 = worldIn.getBlockState(pos.west()).getBlock();
Block block3 = worldIn.getBlockState(pos.east()).getBlock();
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
@Override
public boolean isFullCube()
{
return false;
}

//方块状态太难弄了,我不玩♂你♀行了吧.........
//其实是从家具mod里抄的,太无耻!!!!!!!!
/*
@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
IBlockState state = super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, placer);
return state.withProperty(FACING, placer.getHorizontalFacing());
}
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
{
enumfacing = EnumFacing.SOUTH;
}
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
{
enumfacing = EnumFacing.NORTH;
}
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
{
enumfacing = EnumFacing.EAST;
}
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
{
enumfacing = EnumFacing.WEST;
}
@Override
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
}
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
}*/
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { FACING });
}
*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package WdawningStudio.DawnW.science.block;

import WdawningStudio.DawnW.science.creativetab.CreativeTabsLoader;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;

public class BlockElectricityFurnace extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyBool BURNING = PropertyBool.create("burning");

public BlockElectricityFurnace()
{
super(Material.iron);
this.setUnlocalizedName("electricityFurnace");
this.setHardness(2.5F);
this.setStepSound(Block.soundTypeMetal);
this.setCreativeTab(CreativeTabsLoader.tabEnergy);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)
.withProperty(BURNING, Boolean.FALSE));
}

@Override
protected BlockState createBlockState()
{
return new BlockState(this, FACING, BURNING);
}

@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
int meta, EntityLivingBase placer)
{
IBlockState origin = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
return origin.withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumFacing side, float hitX, float hitY, float hitZ)
{
worldIn.setBlockState(pos, state.cycleProperty(BURNING));
return true;
}

@Override
public IBlockState getStateFromMeta(int meta)
{
EnumFacing facing = EnumFacing.getHorizontal(meta & 3);
Boolean burning = Boolean.valueOf((meta & 4) != 0);
return this.getDefaultState().withProperty(FACING, facing).withProperty(BURNING, burning);
}

@Override
public int getMetaFromState(IBlockState state)
{
int facing = ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
int burning = ((Boolean) state.getValue(BURNING)).booleanValue() ? 4 : 0;
return facing | burning;
}
}
34 changes: 28 additions & 6 deletions src/main/java/WdawningStudio/DawnW/science/block/BlockLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -20,14 +22,16 @@ public class BlockLoader
public static Block magnetBlock = new BlockMagnetBlock();
// public static Block magnetDoor = new BlockMagnetDoor();
//energy
public static Block electricityFurnace = new BlockElectricityFurnace();

public static Block fluidPetroleum = new BlockFluidPetroleum();
//machine
public static Block machineFurnace = new BlockMachineFurnace();
//computer
public static Block simpleComputer = new BlockComputer.SimpleComputer();
public static Block highComputer = new BlockComputer.HighComputer();
public static Block proComputer = new BlockComputer.ProComputer();
public static Block superComputer = new BlockComputer.SuperComputer();
//robot

//color egg

Expand All @@ -42,13 +46,14 @@ public BlockLoader(FMLPreInitializationEvent event)
// register(magnetDoor, "magnet_door");
//energy
register(fluidPetroleum, "petroleum");
register(electricityFurnace, "ele_furnace");
//machine
register(machineFurnace, "iron_furnace");
//computer
register(simpleComputer, "simple_computer");
register(highComputer, "high_computer");
register(proComputer, "pro_computer");
register(superComputer, "super_computer");
//robot

//color egg

}
Expand All @@ -64,13 +69,14 @@ public static void registerRenders()
// registerRender(magnetDoor, "magnet_door");
//energy
registerRender(fluidPetroleum, "petroleum");
registerRender(electricityFurnace, "ele_furnace");
//machine
registerRender(machineFurnace, "iron_furnace");
//computer
registerRender(simpleComputer, "simple_computer");
registerRender(highComputer, "high_computer");
registerRender(proComputer, "pro_computer");
registerRender(superComputer, "super_computer");
//robot

//color egg

}
Expand All @@ -80,9 +86,25 @@ private static void register(Block block, String name)
GameRegistry.registerBlock(block, name);
}

@SuppressWarnings("unchecked")
private static void register(Block block, ItemBlock itemBlock, String name)
{
GameRegistry.registerBlock(block, null, name);
GameRegistry.registerItem(itemBlock, name);
GameData.getBlockItemMap().put(block, itemBlock);
}

@SideOnly(Side.CLIENT)
private static void registerRender(Block block, String name)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(science.MODID + ":" + name, "inventory"));
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0,
new ModelResourceLocation(science.MODID + ":" + name, "inventory"));
}

@SideOnly(Side.CLIENT)
private static void registerRender(Block block, int meta, String name)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), meta,
new ModelResourceLocation(science.MODID + ":" + name, "inventory"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package WdawningStudio.DawnW.science.block;

import WdawningStudio.DawnW.science.creativetab.CreativeTabsLoader;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;

public class BlockMachineFurnace extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyBool BURNING = PropertyBool.create("burning");

public BlockMachineFurnace()
{
super(Material.iron);
this.setUnlocalizedName("machineFurnace");
this.setHardness(2.5F);
this.setStepSound(Block.soundTypeMetal);
this.setCreativeTab(CreativeTabsLoader.tabMachine);
}

@Override
protected BlockState createBlockState()
{
return new BlockState(this, FACING, BURNING);
}

@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
int meta, EntityLivingBase placer)
{
IBlockState origin = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
return origin.withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumFacing side, float hitX, float hitY, float hitZ)
{
worldIn.setBlockState(pos, state.cycleProperty(BURNING));
return true;
}

@Override
public IBlockState getStateFromMeta(int meta)
{
EnumFacing facing = EnumFacing.getHorizontal(meta & 3);
Boolean burning = Boolean.valueOf((meta & 4) != 0);
return this.getDefaultState().withProperty(FACING, facing).withProperty(BURNING, burning);
}

@Override
public int getMetaFromState(IBlockState state)
{
int facing = ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
int burning = ((Boolean) state.getValue(BURNING)).booleanValue() ? 4 : 0;
return facing | burning;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Item getTabIconItem()
@Override
public Item getTabIconItem()
{
return Item.getItemFromBlock(Blocks.furnace);
return Item.getItemFromBlock(BlockLoader.machineFurnace);
}
};
tabComputer = new CreativeTabs("Computer")
Expand Down Expand Up @@ -83,7 +83,7 @@ public Item getTabIconItem()
@Override
public Item getTabIconItem()
{
return ItemLoader.cakeEgg;
return ItemLoader.flanRPG;
}
};
tabColourEgg = new CreativeTabs("ColourEgg")
Expand Down
Loading

0 comments on commit 649bef2

Please sign in to comment.