Search in sources :

Example 1 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class StructureNibiruJungleTemplePieces method generateChest.

@Override
protected boolean generateChest(World world, StructureBoundingBox box, Random rand, int x, int y, int z, ResourceLocation loot) {
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
    if (box.isVecInside(blockpos) && world.getBlockState(blockpos).getBlock() != MPBlocks.INFECTED_CHEST) {
        IBlockState iblockstate = MPBlocks.INFECTED_CHEST.getDefaultState();
        world.setBlockState(blockpos, MPBlocks.INFECTED_CHEST.correctFacing(world, blockpos, iblockstate), 2);
        TileEntity tileentity = world.getTileEntity(blockpos);
        if (tileentity instanceof TileEntityChestMP) {
            ((TileEntityChestMP) tileentity).setLootTable(loot, rand.nextLong());
        }
        return true;
    } else {
        return false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class ComponentCrashedAlienShipPieces method replaceDataBlocks2.

@SuppressWarnings("deprecation")
private static void replaceDataBlocks2(World world, Random rand, Rotation rotation, Template template, BlockPos pos, PlacementSettings settings) {
    Map<BlockPos, String> map = template.getDataBlocks(pos, settings);
    for (Map.Entry<BlockPos, String> entry : map.entrySet()) {
        String dataName = entry.getValue();
        BlockPos dataPos = entry.getKey();
        if ("airlock".equals(dataName)) {
            world.setBlockState(dataPos, GCBlocks.airLockFrame.getStateFromMeta(1), 3);
            TileEntity tile = world.getTileEntity(dataPos);
            if (tile instanceof TileEntityAirLockController) {
                ((TileEntityAirLockController) tile).playerDistanceSelection = 1;
            }
        } else if ("chest_or_crystals".equals(dataName)) {
            if (rand.nextFloat() > 0.95F) {
                world.setBlockState(dataPos, MPBlocks.ALIEN_CHEST.getDefaultState().withRotation(rotation), 3);
                TileEntity tile = world.getTileEntity(dataPos);
                if (tile instanceof TileEntityChestMP) {
                    ((TileEntityChestMP) tile).setLootTable(MPLootTables.CRASHED_ALIEN_SHIP, rand.nextLong());
                }
            } else if (rand.nextFloat() > 0.75F) {
                world.setBlockState(dataPos, GCBlocks.fallenMeteor.getDefaultState(), 3);
                TileEntity tile = world.getTileEntity(dataPos);
                if (tile instanceof TileEntityFallenMeteor) {
                    ((TileEntityFallenMeteor) tile).heatLevel = 0;
                }
            } else {
                world.setBlockState(dataPos, MPBlocks.INFECTED_PURLONITE_CRYSTAL.getDefaultState(), 3);
            }
        } else if ("arclamp_west".equals(dataName)) {
            world.setBlockState(dataPos, GCBlocks.brightLamp.getDefaultState().withProperty(BlockBrightLamp.FACING, rotation.rotate(EnumFacing.WEST)), 3);
        } else if ("arclamp_east".equals(dataName)) {
            world.setBlockState(dataPos, GCBlocks.brightLamp.getDefaultState().withProperty(BlockBrightLamp.FACING, rotation.rotate(EnumFacing.EAST)), 3);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAirLockController(micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController) TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) TileEntityFallenMeteor(micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map)

Example 3 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class DoubleChestItemHandlerMP method getStackInSlot.

@Override
@Nonnull
public ItemStack getStackInSlot(int slot) {
    boolean accessingUpperChest = slot < 27;
    int targetSlot = accessingUpperChest ? slot : slot - 27;
    TileEntityChestMP chest = this.getChest(accessingUpperChest);
    return chest != null ? chest.getStackInSlot(targetSlot) : ItemStack.EMPTY;
}
Also used : TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) Nonnull(javax.annotation.Nonnull)

Example 4 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class DoubleChestItemHandlerMP method insertItem.

@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack itemStack, boolean simulate) {
    boolean accessingUpperChest = slot < 27;
    int targetSlot = accessingUpperChest ? slot : slot - 27;
    TileEntityChestMP chest = this.getChest(accessingUpperChest);
    if (chest == null) {
        return itemStack;
    }
    int starting = itemStack.getCount();
    ItemStack ret = chest.getSingleChestHandler().insertItem(targetSlot, itemStack, simulate);
    if (ret.getCount() != starting && !simulate) {
        chest = this.getChest(!accessingUpperChest);
        if (chest != null) {
            chest.markDirty();
        }
    }
    return ret;
}
Also used : TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 5 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class DoubleChestItemHandlerMP method equals.

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (o == null || this.getClass() != o.getClass()) {
        return false;
    }
    DoubleChestItemHandlerMP that = (DoubleChestItemHandlerMP) o;
    if (this.hashCode != that.hashCode) {
        return false;
    }
    final TileEntityChestMP otherChest = this.getOtherChest();
    if (this.mainChestIsUpper == that.mainChestIsUpper) {
        return Objects.equal(this.mainChest, that.mainChest) && Objects.equal(otherChest, that.getOtherChest());
    } else {
        return Objects.equal(this.mainChest, that.getOtherChest()) && Objects.equal(otherChest, that.mainChest);
    }
}
Also used : TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP)

Aggregations

TileEntityChestMP (stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP)15 BlockPos (net.minecraft.util.math.BlockPos)10 TileEntity (net.minecraft.tileentity.TileEntity)8 Nonnull (javax.annotation.Nonnull)3 ItemStack (net.minecraft.item.ItemStack)3 Map (java.util.Map)2 IBlockState (net.minecraft.block.state.IBlockState)2 MinecraftServer (net.minecraft.server.MinecraftServer)2 EnumFacing (net.minecraft.util.EnumFacing)2 Rotation (net.minecraft.util.Rotation)2 StructureBoundingBox (net.minecraft.world.gen.structure.StructureBoundingBox)2 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)2 Template (net.minecraft.world.gen.structure.template.Template)2 TemplateManager (net.minecraft.world.gen.structure.template.TemplateManager)2 Method (java.lang.reflect.Method)1 Nullable (javax.annotation.Nullable)1 TileEntityAirLockController (micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController)1 TileEntityEnergyStorageModule (micdoodle8.mods.galacticraft.core.tile.TileEntityEnergyStorageModule)1 TileEntityFallenMeteor (micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor)1 TileEntityLaserTurret (micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret)1