Skip to content

Commit

Permalink
Fixed shulker box not generating
Browse files Browse the repository at this point in the history
  • Loading branch information
adudewithapc committed Jul 3, 2017
1 parent 199913f commit cc71b87
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/main/java/thatmartinguy/thedarkness/TheDarkness.java
Expand Up @@ -17,6 +17,7 @@
import thatmartinguy.thedarkness.command.CommandDimension;
import thatmartinguy.thedarkness.command.CommandTransforming;
import thatmartinguy.thedarkness.data.capability.PlayerHostProvider;
import thatmartinguy.thedarkness.init.ModBlocks;
import thatmartinguy.thedarkness.init.ModLootTables;
import thatmartinguy.thedarkness.network.ReliquaryCraftedMessage;
import thatmartinguy.thedarkness.proxy.IProxy;
Expand All @@ -40,6 +41,8 @@ public ItemStack getTabIconItem()
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
ModBlocks.registerTileEntities();

network = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID);

int networkID = -1;
Expand All @@ -62,7 +65,7 @@ public void init(FMLInitializationEvent event)
public static TheDarkness instance;

@EventHandler
public void s(FMLServerStartingEvent event)
public void registerDebugCommands(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandDimension());
event.registerServerCommand(new CommandTransforming());
Expand Down
Expand Up @@ -84,4 +84,10 @@ public void resetHiddenBlock(World world, BlockPos pos)
world.setBlockState(pos, state);
}
}

@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
}
35 changes: 35 additions & 0 deletions src/main/java/thatmartinguy/thedarkness/block/BlockSeeThrough.java
@@ -0,0 +1,35 @@
package thatmartinguy.thedarkness.block;

import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;

public class BlockSeeThrough extends BlockBase
{
public BlockSeeThrough(String name, Material materialIn)
{
super(name, materialIn);
this.setCreativeTab(null);
}

@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.INVISIBLE;
}

@Override
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
return false;
}

@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
}
@@ -1,10 +1,18 @@
package thatmartinguy.thedarkness.event;

import ibxm.Player;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.Sound;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.World;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
Expand All @@ -13,6 +21,8 @@
import thatmartinguy.thedarkness.init.ModPotions;
import thatmartinguy.thedarkness.util.Reference;

import java.util.Random;

@EventBusSubscriber
public class CapabilityEventHandler
{
Expand Down Expand Up @@ -52,4 +62,19 @@ public static void handleFading(LivingUpdateEvent event)
}
}
}

@SubscribeEvent
public static void playerTransforming(LivingUpdateEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if(player.getCapability(PlayerHostProvider.PLAYER_HOST_CAPABILITY, null).isTransforming())
{
World world = player.getEntityWorld();
if(!world.isRemote)
player.addPotionEffect(new PotionEffect(ModPotions.potionFading, 19));
}
}
}
}
20 changes: 19 additions & 1 deletion src/main/java/thatmartinguy/thedarkness/init/ModBlocks.java
Expand Up @@ -4,17 +4,27 @@
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import thatmartinguy.thedarkness.block.*;
import thatmartinguy.thedarkness.tileentity.TileEntityHidden;

@EventBusSubscriber
public class ModBlocks
{
public static BlockHidden blockHidden;
public static BlockBase blockSeeThrough;

public static final Block[] BLOCKS = {
blockHidden = new BlockHidden("blockHidden", Material.AIR)
blockHidden = new BlockHidden("blockHidden", Material.AIR),
blockSeeThrough = new BlockSeeThrough("blockSeeThrough", Material.STRUCTURE_VOID)
};

public static final Class<? extends TileEntity>[] TILE_ENTITIES = new Class[]{
TileEntityHidden.class
};

@SubscribeEvent
Expand All @@ -31,4 +41,12 @@ public static void registerItemBlocks(RegistryEvent.Register<Item> event)
event.getRegistry().register(new ItemBlock(block).setUnlocalizedName(block.getUnlocalizedName()).setRegistryName(block.getRegistryName()));
}
}

public static void registerTileEntities()
{
for(Class<? extends TileEntity> tileEntity : TILE_ENTITIES)
{
GameRegistry.registerTileEntity(tileEntity, "tileEntityHidden");
}
}
}
Expand Up @@ -83,6 +83,7 @@ public ItemStack handleDrinking(ItemStack itemStack, World world, EntityLivingBa
case 2:
world.setWorldTime(18000);
reduceUses(itemStack);
createHole(world, player.getPosition());
if(world.isRemote)
{
world.playSound(player, new BlockPos(player), SoundEvents.BLOCK_PORTAL_TRIGGER, SoundCategory.PLAYERS, 0.5F, 0.2F);
Expand All @@ -93,7 +94,6 @@ public ItemStack handleDrinking(ItemStack itemStack, World world, EntityLivingBa
player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 200));
player.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 100));
player.addPotionEffect(new PotionEffect(ModPotions.potionFading, 24000));
createHole(world, player.getPosition());
}
break;
case 3:
Expand Down
@@ -1,12 +1,13 @@
package thatmartinguy.thedarkness.world.gen;

import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityShulkerBox;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
Expand All @@ -19,14 +20,19 @@ public class WorldGenReliquaryChest implements IWorldGenerator
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
if(world.provider.getDimensionType() == DimensionType.THE_END)
if (world instanceof WorldServer)
{
BlockPos chestPosition = world.getSpawnPoint().offset(EnumFacing.NORTH);
world.setBlockState(chestPosition, Blocks.BLACK_SHULKER_BOX.getDefaultState(), 3);
if (world.getTileEntity(chestPosition) instanceof TileEntityShulkerBox)
WorldServer worldServer = (WorldServer) world;

if(worldServer.provider.getDimensionType() == DimensionType.THE_END && chunkX == worldServer.getSpawnCoordinate().getX() >> 4 && chunkZ == worldServer.getSpawnCoordinate().getZ() >> 4)
{
TileEntityShulkerBox entityBox = (TileEntityShulkerBox) world.getTileEntity(chestPosition);
entityBox.setLootTable(ModLootTables.lootReliquary, 1);
BlockPos chestPosition = worldServer.getSpawnCoordinate().offset(EnumFacing.NORTH);
world.setBlockState(chestPosition, Blocks.BLACK_SHULKER_BOX.getDefaultState(), 3);
if (world.getTileEntity(chestPosition) instanceof TileEntityShulkerBox)
{
TileEntityShulkerBox entityBox = (TileEntityShulkerBox) world.getTileEntity(chestPosition);
entityBox.setLootTable(ModLootTables.lootReliquary, 1);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/thedarkness/lang/en_US.lang
Expand Up @@ -6,7 +6,7 @@ item.thedarkness:itemreliquary.name=Reliquary
#tile.thedarkness:tilename.name

# Potions

thedarkness:potionfading=Fading

# Creative Tab
itemGroup.thedarkness=The Darkness

0 comments on commit cc71b87

Please sign in to comment.