Permalink
Browse files

Fixed skull lighting and dupe bugs

  • Loading branch information...
Ri5ux committed Dec 28, 2018
1 parent c7662b3 commit 574519ec290b64c987d68ed57a2f58b8219cf887
Showing with 38 additions and 16 deletions.
  1. +38 −16 src/main/java/org/avp/block/BlockSkull.java
@@ -1,6 +1,5 @@
package org.avp.block;

import java.util.List;
import java.util.Random;

import org.avp.tile.TileEntitySkull;
@@ -16,12 +15,14 @@
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
@@ -34,7 +35,7 @@
public BlockSkull()
{
super(Material.IRON);
this.setLightOpacity(2);
this.setLightOpacity(1);
}

@Override
@@ -43,6 +44,13 @@ public boolean isOpaqueCube(IBlockState state)
return false;
}

// Controls light passthrough
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}

@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
@@ -86,7 +94,7 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity
skull.setRotationYAxis(Entities.getEntityFacingRotY(placer));
}
}

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
@@ -95,12 +103,12 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
if (tile != null && tile instanceof TileEntitySkull && player != null)
{
TileEntitySkull skull = (TileEntitySkull) tile;

if (this.canChangeOrientation())
{
EnumOrientation orientation = EnumOrientation.WALL;
switch(facing)

switch (facing)
{
case UP:
if (player.isSneaking())
@@ -115,43 +123,57 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
default:
orientation = EnumOrientation.WALL;
}

skull.setOrientation(orientation);
System.out.println("orientation set to " + orientation);
}
}

return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ);
}

@Override
public boolean hasTileEntity(IBlockState state)
{
return true;
}

public boolean canChangeOrientation()
{
return false;
}

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
System.out.println("get item dropped");
System.out.println(Item.getItemFromBlock(this));
return super.getItemDropped(state, rand, fortune);
}

@Override
public void onPlayerDestroy(World worldIn, BlockPos pos, IBlockState state)
{
dropBlockAsItem(worldIn, pos, state, 1);
}

@Override
public void onExplosionDestroy(World worldIn, BlockPos pos, Explosion explosionIn)
{
dropBlockAsItem(worldIn, pos, null, 1);
}

public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
Random rand = world instanceof World ? ((World) world).rand : RANDOM;
Item item = this.getItemDropped(state, rand, fortune);

if (item != Items.AIR)
{
drops.add(new ItemStack(item, 1, this.damageDropped(state)));
}
}

@Override
public boolean canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player)
{
return false;
}
}

0 comments on commit 574519e

Please sign in to comment.