use of net.minecraft.item.BlockItem in project Overloaded by CJ-MC-Mods.
the class RenderMultiToolAssist method renderWorldLastEvent.
@SubscribeEvent
public static void renderWorldLastEvent(RenderWorldLastEvent event) {
float partialTick = Minecraft.getInstance().getFrameTime();
PlayerEntity player = Minecraft.getInstance().player;
if (player.getMainHandItem().getItem() != ModItems.multiTool)
return;
RayTraceResult resultPick = player.pick(OverloadedConfig.INSTANCE.multiToolConfig.reach, partialTick, false);
if (resultPick.getType() == RayTraceResult.Type.MISS || !(resultPick instanceof BlockRayTraceResult)) {
return;
}
BlockRayTraceResult result = ((BlockRayTraceResult) resultPick);
ItemStack stack = ModItems.multiTool.getSelectedBlockItemStack(player.getMainHandItem());
BlockState state;
if (stack.getItem() instanceof BlockItem) {
state = ((BlockItem) stack.getItem()).getBlock().defaultBlockState();
state = state.getStateAtViewpoint(player.getCommandSenderWorld(), result.getBlockPos(), player.getEyePosition(partialTick));
state = state.getBlock().getStateForPlacement(new BlockItemUseContextPublic(player.getCommandSenderWorld(), player, Hand.MAIN_HAND, stack, result));
} else {
state = Blocks.COBBLESTONE.defaultBlockState();
}
switch(getAssistMode()) {
case PLACE_PREVIEW:
if (!stack.isEmpty() && state != null)
renderBlockPreview(event, result, state);
break;
case REMOVE_PREVIEW:
renderRemovePreview(event, result);
break;
case BOTH_PREVIEW:
renderRemovePreview(event, result);
if (!stack.isEmpty() && state != null)
renderBlockPreview(event, result, state);
}
}
use of net.minecraft.item.BlockItem in project BluePower by Qmunity.
the class MicroblockRecipe method assemble.
@Override
public ItemStack assemble(CraftingInventory inv) {
for (int i = 0; i < inv.getContainerSize(); ++i) {
ItemStack stack = inv.getItem(i);
if (!stack.isEmpty() && stack.getItem() instanceof BlockItem) {
if (Block.byItem(stack.getItem()).defaultBlockState().getShape(null, null) == VoxelShapes.block()) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", stack.getItem().getRegistryName().toString());
ItemStack outStack = new ItemStack(BPBlocks.half_block, 2);
outStack.setTag(nbt);
outStack.setHoverName(new TranslationTextComponent(stack.getItem().getDescriptionId()).append(" ").append(new TranslationTextComponent(BPBlocks.half_block.getDescriptionId())));
return outStack;
} else if (Block.byItem(stack.getItem()) == BPBlocks.half_block) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", stack.getTag().getString("block"));
ItemStack outStack = new ItemStack(BPBlocks.panel, 2);
outStack.setTag(nbt);
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(nbt.getString("block")));
outStack.setHoverName(new TranslationTextComponent(block.getDescriptionId()).append(" ").append(new TranslationTextComponent(BPBlocks.panel.getDescriptionId())));
return outStack;
} else if (Block.byItem(stack.getItem()) == BPBlocks.panel) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", stack.getTag().getString("block"));
ItemStack outStack = new ItemStack(BPBlocks.cover, 2);
outStack.setTag(nbt);
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(nbt.getString("block")));
outStack.setHoverName(new TranslationTextComponent(block.getDescriptionId()).append(" ").append(new TranslationTextComponent(BPBlocks.cover.getDescriptionId())));
return outStack;
}
}
}
return ItemStack.EMPTY;
}
use of net.minecraft.item.BlockItem in project BluePower by Qmunity.
the class MicroblockRecipe method matches.
@Override
public boolean matches(CraftingInventory inv, World worldIn) {
int blockCount = 0;
int saw = 0;
for (int i = 0; i < inv.getContainerSize(); ++i) {
ItemStack stack = inv.getItem(i);
if (!stack.isEmpty()) {
if (stack.getItem() instanceof BlockItem && (Block.byItem(stack.getItem()) instanceof BlockBPMicroblock || !Block.byItem(stack.getItem()).hasTileEntity(Block.byItem(stack.getItem()).defaultBlockState()))) {
VoxelShape shape = null;
try {
shape = Block.byItem(stack.getItem()).defaultBlockState().getShape(null, null);
} catch (NullPointerException ignored) {
// Shulker Boxes try to query the Tile Entity
}
if (shape == VoxelShapes.block() || Block.byItem(stack.getItem()) == BPBlocks.half_block || Block.byItem(stack.getItem()) == BPBlocks.panel) {
blockCount++;
}
} else if (stack.getItem() instanceof ItemSaw) {
saw++;
} else {
return false;
}
}
}
return blockCount == 1 && saw == 1;
}
use of net.minecraft.item.BlockItem in project Bookshelf by Darkhax-Minecraft.
the class RegistryHelper method generateBlockItem.
private void generateBlockItem(ForgeRegistryHelper<Block> registry, Block block) {
final Item.Properties itemProps = block instanceof IBookshelfBlock ? ((IBookshelfBlock) block).getItemBlockProperties() : new Item.Properties();
if (itemProps != null) {
final Item item = new BlockItem(block, itemProps);
item.setRegistryName(block.getRegistryName());
this.items.register(item);
}
}
use of net.minecraft.item.BlockItem in project BluePower by Qmunity.
the class GuiAnimatedStat method render.
@Override
public void render(MatrixStack matrixStack, FontRenderer fontRenderer, float zLevel, float partialTicks) {
int renderBaseX = (int) (oldBaseX + (baseX - oldBaseX) * partialTicks);
int renderAffectedY = (int) (oldAffectedY + (affectedY - oldAffectedY) * partialTicks);
int renderWidth = (int) (oldWidth + (width - oldWidth) * partialTicks);
int renderHeight = (int) (oldHeight + (height - oldHeight) * partialTicks);
if (leftSided)
renderWidth *= -1;
AbstractGui.fill(matrixStack, renderBaseX, renderAffectedY, /* + 1 */
renderBaseX + renderWidth, /*- 1*/
renderAffectedY + renderHeight, backGroundColor);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glLineWidth(3.0F);
GL11.glColor4d(0, 0, 0, 1);
Tessellator tess = Tessellator.getInstance();
BufferBuilder buff = tess.getBuilder();
buff.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_TEX);
buff.vertex(renderBaseX, renderAffectedY, zLevel);
buff.vertex(renderBaseX + renderWidth, renderAffectedY, zLevel);
buff.vertex(renderBaseX + renderWidth, renderAffectedY + renderHeight, zLevel);
buff.vertex(renderBaseX, renderAffectedY + renderHeight, zLevel);
tess.end();
GL11.glEnable(GL11.GL_TEXTURE_2D);
if (leftSided)
renderWidth *= -1;
// if done expanding, draw the information
if (doneExpanding) {
GL11.glPushMatrix();
GL11.glTranslated(renderBaseX + (leftSided ? -renderWidth : 16), renderAffectedY, 0);
GL11.glScaled(textSize, textSize, textSize);
GL11.glTranslated(-renderBaseX - (leftSided ? -renderWidth : 16), -renderAffectedY, 0);
fontRenderer.drawShadow(matrixStack, title, renderBaseX + (leftSided ? -renderWidth + 2 : 18), renderAffectedY + 2, 0xFFFF00);
for (int i = 0; i < textList.size(); i++) {
if (textList.get(i).contains("\u00a70") || textList.get(i).contains(TextFormatting.DARK_RED.toString())) {
fontRenderer.draw(matrixStack, textList.get(i), renderBaseX + (leftSided ? -renderWidth + 2 : 18), renderAffectedY + i * 10 + 12, 0xFFFFFF);
} else {
fontRenderer.drawShadow(matrixStack, textList.get(i), renderBaseX + (leftSided ? -renderWidth + 2 : 18), renderAffectedY + i * 10 + 12, 0xFFFFFF);
}
}
GL11.glPopMatrix();
}
if (renderHeight > 16 && renderWidth > 16) {
GL11.glColor4d(1, 1, 1, 1);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (iStack == null) {
if (iconResLoc == null)
iconResLoc = new ResourceLocation(texture);
drawTexture(iconResLoc, renderBaseX - (leftSided ? 16 : 0), renderAffectedY);
} else if (gui != null || !(iStack.getItem() instanceof BlockItem)) {
renderItem(fontRenderer, renderBaseX - (leftSided ? 16 : 0), renderAffectedY, iStack);
}
}
}
Aggregations