diff --git a/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java index c5609ee1..665fa066 100644 --- a/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java @@ -175,7 +175,6 @@ public class UnicopiaClient extends UClient { public static void preEntityRender(RenderLivingEvent.Pre event) { if (event.getEntity() instanceof EntityPlayer) { IPlayer iplayer = PlayerSpeciesList.instance().getPlayer((EntityPlayer)event.getEntity()); - System.out.println(event.getEntity().getName()); /*if (!MineLP.modIsActive()) { float roll = iplayer.getCamera().calculateRoll(); diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockGlowingGem.java b/src/main/java/com/minelittlepony/unicopia/block/BlockGlowingGem.java index 2a4c221e..a3a8cafa 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/BlockGlowingGem.java +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockGlowingGem.java @@ -3,13 +3,24 @@ package com.minelittlepony.unicopia.block; import java.util.Random; import com.minelittlepony.unicopia.CloudType; +import com.minelittlepony.unicopia.UItems; import com.minelittlepony.unicopia.UParticles; import com.minelittlepony.unicopia.particle.Particles; import net.minecraft.block.BlockTorch; import net.minecraft.block.SoundType; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.NonNullList; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -17,6 +28,7 @@ import net.minecraft.world.World; public class BlockGlowingGem extends BlockTorch implements ICloudBlock { + public static PropertyBool ON = PropertyBool.create("on"); private static final double A = 5/16D; private static final double B = 6/16D; @@ -58,6 +70,12 @@ public class BlockGlowingGem extends BlockTorch implements ICloudBlock { setHardness(0); setLightLevel(1); setSoundType(SoundType.GLASS); + setTickRandomly(true); + + setDefaultState(blockState.getBaseState() + .withProperty(FACING, EnumFacing.UP) + .withProperty(ON, true) + ); } @Override @@ -72,12 +90,35 @@ public class BlockGlowingGem extends BlockTorch implements ICloudBlock { } } + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + + if (!state.getValue(ON)) { + ItemStack held = player.getHeldItem(hand); + if (!held.isEmpty() && (held.getItem() == Items.FLINT_AND_STEEL || held.getItem() == Items.FIRE_CHARGE)) { + + world.playSound(null, pos, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + world.setBlockState(pos, state.withProperty(ON, true)); + + if (held.getItem() == Items.FLINT_AND_STEEL) { + held.damageItem(1, player); + } else if (!player.capabilities.isCreativeMode) { + held.shrink(1); + } + } + + return true; + } + + return false; + } + @Override public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { EnumFacing facing = state.getValue(FACING); double x = pos.getX() + 0.5; - double y = pos.getY() + 0.7; + double y = pos.getY() + 1; double z = pos.getZ() + 0.5; double drop = 0.22D; @@ -91,15 +132,93 @@ public class BlockGlowingGem extends BlockTorch implements ICloudBlock { z += variance * facing.getZOffset(); } - for (int i = 0; i < 3; i++) { - Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, - x - 0.3, y, z - 0.3, - rand.nextFloat(), rand.nextFloat(), rand.nextFloat()); + if (state.getValue(ON)) { + for (int i = 0; i < 3; i++) { + Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, + x - 0.3, y - 0.3, z - 0.3, + rand.nextFloat(), rand.nextFloat(), rand.nextFloat()); + } + } else { + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, x, y, z, 0, 0, 0); } } + @Override + public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { + if (world.isRainingAt(pos)) { + if (state.getValue(ON)) { + world.playSound(null, pos, SoundEvents.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + world.setBlockState(pos, state.withProperty(ON, false)); + } + } else { + if (!state.getValue(ON)) { + world.playSound(null, pos, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + world.setBlockState(pos, state.withProperty(ON, true)); + } + } + } + + @Override + public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { + return state.getValue(ON) && side == EnumFacing.DOWN ? state.getWeakPower(world, pos, side) : 0; + } + + @Override + public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { + return state.getValue(ON) && state.getValue(FACING) != side ? 12 : 0; + } + @Override public CloudType getCloudMaterialType(IBlockState blockState) { return CloudType.ENCHANTED; } + + @Override + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + drops.add(new ItemStack(Items.STICK)); + + Random rand = world instanceof World ? ((World)world).rand : RANDOM; + + if (rand.nextInt(10) == 0) { + drops.add(new ItemStack(UItems.spell)); + } else { + drops.add(new ItemStack(UItems.curse)); + } + } + + @Override + @Deprecated + public int getLightValue(IBlockState state) { + if (state.getValue(ON)) { + return super.getLightValue(state); + } + + return 0; + } + + @Override + public IBlockState getStateFromMeta(int meta) { + IBlockState iblockstate = this.getDefaultState(); + + int facing = (meta % 5) + 1; + + return iblockstate + .withProperty(FACING, EnumFacing.byIndex(facing)) + .withProperty(ON, meta > 5); + } + + @Override + public int getMetaFromState(IBlockState state) { + int meta = Math.max(0, state.getValue(FACING).getIndex() - 1); + if (state.getValue(ON)) { + meta += EnumFacing.VALUES.length; + } + + return meta; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, FACING, ON); + } } diff --git a/src/main/resources/assets/unicopia/blockstates/enchanted_torch.json b/src/main/resources/assets/unicopia/blockstates/enchanted_torch.json index 67815777..b7f31c6f 100644 --- a/src/main/resources/assets/unicopia/blockstates/enchanted_torch.json +++ b/src/main/resources/assets/unicopia/blockstates/enchanted_torch.json @@ -1,9 +1,14 @@ { "variants": { - "facing=up": { "model": "unicopia:enchanted_torch" }, - "facing=east": { "model": "unicopia:enchanted_torch_wall" }, - "facing=south": { "model": "unicopia:enchanted_torch_wall", "y": 90 }, - "facing=west": { "model": "unicopia:enchanted_torch_wall", "y": 180 }, - "facing=north": { "model": "unicopia:enchanted_torch_wall", "y": 270 } + "facing=up,on=true": { "model": "unicopia:enchanted_torch_on" }, + "facing=east,on=true": { "model": "unicopia:enchanted_torch_wall_on" }, + "facing=south,on=true": { "model": "unicopia:enchanted_torch_wall_on", "y": 90 }, + "facing=west,on=true": { "model": "unicopia:enchanted_torch_wall_on", "y": 180 }, + "facing=north,on=true": { "model": "unicopia:enchanted_torch_wall_on", "y": 270 }, + "facing=up,on=false": { "model": "unicopia:enchanted_torch_off" }, + "facing=east,on=false": { "model": "unicopia:enchanted_torch_wall_off" }, + "facing=south,on=false": { "model": "unicopia:enchanted_torch_wall_off", "y": 90 }, + "facing=west,on=false": { "model": "unicopia:enchanted_torch_wall_off", "y": 180 }, + "facing=north,on=false": { "model": "unicopia:enchanted_torch_wall_off", "y": 270 } } } diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index 82d83159..482e140c 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -16,6 +16,8 @@ tile.apple_sapling.name=Apple Seeds tile.sugar_block.name=Block of Sugar +tile.enchanted_torch.name=Stone Lamp + item.cloud_matter.name=Lump of Cloud item.cloud.small.name=Bucking Bronco item.cloud.medium.name=Construction Cloud diff --git a/src/main/resources/assets/unicopia/models/block/enchanted_torch_off.json b/src/main/resources/assets/unicopia/models/block/enchanted_torch_off.json new file mode 100644 index 00000000..6994b958 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/enchanted_torch_off.json @@ -0,0 +1,6 @@ +{ + "parent": "unicopia:block/torch_tall", + "textures": { + "torch": "unicopia:blocks/enchanted_torch_off" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/enchanted_torch_on.json b/src/main/resources/assets/unicopia/models/block/enchanted_torch_on.json new file mode 100644 index 00000000..00199fa1 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/enchanted_torch_on.json @@ -0,0 +1,6 @@ +{ + "parent": "unicopia:block/torch_tall", + "textures": { + "torch": "unicopia:blocks/enchanted_torch_on" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/enchanted_torch_wall_off.json b/src/main/resources/assets/unicopia/models/block/enchanted_torch_wall_off.json new file mode 100644 index 00000000..e4c0eb45 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/enchanted_torch_wall_off.json @@ -0,0 +1,6 @@ +{ + "parent": "unicopia:block/torch_tall_wall", + "textures": { + "torch": "unicopia:blocks/enchanted_torch_off" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/enchanted_torch_wall_on.json b/src/main/resources/assets/unicopia/models/block/enchanted_torch_wall_on.json new file mode 100644 index 00000000..c2a8c556 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/enchanted_torch_wall_on.json @@ -0,0 +1,6 @@ +{ + "parent": "unicopia:block/torch_tall_wall", + "textures": { + "torch": "unicopia:blocks/enchanted_torch_on" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/enchanted_torch.json b/src/main/resources/assets/unicopia/models/block/torch_tall.json similarity index 81% rename from src/main/resources/assets/unicopia/models/block/enchanted_torch.json rename to src/main/resources/assets/unicopia/models/block/torch_tall.json index bd7c7174..0e47119a 100644 --- a/src/main/resources/assets/unicopia/models/block/enchanted_torch.json +++ b/src/main/resources/assets/unicopia/models/block/torch_tall.json @@ -1,8 +1,7 @@ { "ambientocclusion": false, "textures": { - "torch": "blocks/torch_on", - "particle": "blocks/torch_on" + "particle": "#torch" }, "elements": [ { "from": [ 7, 0, 7 ], @@ -10,7 +9,7 @@ "shade": false, "faces": { "down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" }, - "up": { "uv": [ 7, 6, 9, 8 ], "texture": "#torch" }, + "up": { "uv": [ 7, 0, 9, 2 ], "texture": "#torch" }, "north": { "uv": [ 7, 0, 9, 16 ], "texture": "#torch" }, "south": { "uv": [ 7, 0, 9, 16 ], "texture": "#torch" }, "west": { "uv": [ 7, 0, 9, 16 ], "texture": "#torch" }, diff --git a/src/main/resources/assets/unicopia/models/block/torch_tall_wall.json b/src/main/resources/assets/unicopia/models/block/torch_tall_wall.json new file mode 100644 index 00000000..52ae4f46 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/torch_tall_wall.json @@ -0,0 +1,35 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "#torch" + }, + "elements": [ + { "from": [ -1, 3.5, 7 ], + "to": [ 1, 19.5, 9 ], + "rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 }, + "shade": false, + "faces": { + "down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" }, + "up": { "uv": [ 7, 0, 9, 2 ], "texture": "#torch" } + } + }, + { "from": [ -1, 3.5, 0 ], + "to": [ 1, 19.5, 16 ], + "rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 }, + "shade": false, + "faces": { + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" } + } + }, + { "from": [ -8, 3.5, 7 ], + "to": [ 8, 19.5, 9 ], + "rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 }, + "shade": false, + "faces": { + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" } + } + } + ] +} diff --git a/src/main/resources/assets/unicopia/models/item/enchanted_torch.json b/src/main/resources/assets/unicopia/models/item/enchanted_torch.json index 4e6da468..360872bd 100644 --- a/src/main/resources/assets/unicopia/models/item/enchanted_torch.json +++ b/src/main/resources/assets/unicopia/models/item/enchanted_torch.json @@ -1,6 +1,6 @@ { "parent": "item/generated", "textures": { - "layer0": "blocks/torch_on" + "layer0": "unicopia:blocks/enchanted_torch_on" } } diff --git a/src/main/resources/assets/unicopia/recipes/enchanted_torch.json b/src/main/resources/assets/unicopia/recipes/enchanted_torch.json new file mode 100644 index 00000000..35d0d927 --- /dev/null +++ b/src/main/resources/assets/unicopia/recipes/enchanted_torch.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + " #", + "/ " + ], + "key": { + "/": [ + { "item": "minecraft:stick" } + ], + "#": [ + { "item": "unicopia:gem" } + ] + }, + "result": { "item": "unicopia:enchanted_torch", "count": 1 } +} diff --git a/src/main/resources/assets/unicopia/textures/blocks/enchanted_torch_off.png b/src/main/resources/assets/unicopia/textures/blocks/enchanted_torch_off.png new file mode 100644 index 00000000..b4057d5c Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/blocks/enchanted_torch_off.png differ diff --git a/src/main/resources/assets/unicopia/textures/blocks/enchanted_torch_on.png b/src/main/resources/assets/unicopia/textures/blocks/enchanted_torch_on.png new file mode 100644 index 00000000..984bd8fc Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/blocks/enchanted_torch_on.png differ