Fully implemented stone lamps (enchanted_torches)

This commit is contained in:
Sollace 2019-02-10 14:37:31 +02:00
parent eeb35bba9c
commit 9a3c8bc672
14 changed files with 214 additions and 15 deletions

View file

@ -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();

View file

@ -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<ItemStack> 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);
}
}

View file

@ -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 }
}
}

View file

@ -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

View file

@ -0,0 +1,6 @@
{
"parent": "unicopia:block/torch_tall",
"textures": {
"torch": "unicopia:blocks/enchanted_torch_off"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "unicopia:block/torch_tall",
"textures": {
"torch": "unicopia:blocks/enchanted_torch_on"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "unicopia:block/torch_tall_wall",
"textures": {
"torch": "unicopia:blocks/enchanted_torch_off"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "unicopia:block/torch_tall_wall",
"textures": {
"torch": "unicopia:blocks/enchanted_torch_on"
}
}

View file

@ -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" },

View file

@ -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" }
}
}
]
}

View file

@ -1,6 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "blocks/torch_on"
"layer0": "unicopia:blocks/enchanted_torch_on"
}
}

View file

@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
" #",
"/ "
],
"key": {
"/": [
{ "item": "minecraft:stick" }
],
"#": [
{ "item": "unicopia:gem" }
]
},
"result": { "item": "unicopia:enchanted_torch", "count": 1 }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B