mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Made coal generator rotate properly with the new texture
This commit is contained in:
parent
00edb13a77
commit
e900b00d3f
2 changed files with 40 additions and 3 deletions
|
@ -18,7 +18,9 @@ import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -27,6 +29,7 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.EnumParticleTypes;
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
@ -35,6 +38,8 @@ import java.util.Random;
|
||||||
|
|
||||||
public class BlockCoalGenerator extends BlockContainerBase{
|
public class BlockCoalGenerator extends BlockContainerBase{
|
||||||
|
|
||||||
|
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3);
|
||||||
|
|
||||||
public BlockCoalGenerator(String name){
|
public BlockCoalGenerator(String name){
|
||||||
super(Material.ROCK, name);
|
super(Material.ROCK, name);
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
this.setHarvestLevel("pickaxe", 0);
|
||||||
|
@ -75,6 +80,26 @@ public class BlockCoalGenerator extends BlockContainerBase{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||||
|
|
||||||
|
if(rotation == 0){
|
||||||
|
world.setBlockState(pos, this.getStateFromMeta(0), 2);
|
||||||
|
}
|
||||||
|
if(rotation == 1){
|
||||||
|
world.setBlockState(pos, this.getStateFromMeta(3), 2);
|
||||||
|
}
|
||||||
|
if(rotation == 2){
|
||||||
|
world.setBlockState(pos, this.getStateFromMeta(1), 2);
|
||||||
|
}
|
||||||
|
if(rotation == 3){
|
||||||
|
world.setBlockState(pos, this.getStateFromMeta(2), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumRarity getRarity(ItemStack stack){
|
public EnumRarity getRarity(ItemStack stack){
|
||||||
return EnumRarity.RARE;
|
return EnumRarity.RARE;
|
||||||
|
@ -85,4 +110,9 @@ public class BlockCoalGenerator extends BlockContainerBase{
|
||||||
this.dropInventory(world, pos);
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PropertyInteger getMetaProperty(){
|
||||||
|
return META;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,21 @@
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"model": "minecraft:cube_bottom_top",
|
"model": "minecraft:cube_bottom_top",
|
||||||
"textures": {
|
"textures": {
|
||||||
"side": "actuallyadditions:blocks/blockCoalGenerator",
|
"side": "actuallyadditions:blocks/blockCoalGeneratorSide",
|
||||||
"bottom": "actuallyadditions:blocks/blockCoalGeneratorBottom",
|
"bottom": "actuallyadditions:blocks/blockCoalGeneratorBottom",
|
||||||
"top": "actuallyadditions:blocks/blockCoalGeneratorTop"
|
"top": "actuallyadditions:blocks/blockCoalGeneratorTop",
|
||||||
|
"north": "actuallyadditions:blocks/blockCoalGenerator"
|
||||||
},
|
},
|
||||||
"transform": "forge:default-block"
|
"transform": "forge:default-block"
|
||||||
},
|
},
|
||||||
"variants": {
|
"variants": {
|
||||||
"normal": [{}],
|
"normal": [{}],
|
||||||
"inventory": [{}]
|
"inventory": [{}],
|
||||||
|
"meta": {
|
||||||
|
"0": { "y" : 0 },
|
||||||
|
"1": { "y" : 180 },
|
||||||
|
"2": { "y" : 270 },
|
||||||
|
"3": { "y" : 90 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue