@Override public BaseItemStack getItemInHand(HandSide handSide) { ItemStack is = this.player.getHeldItem(handSide == HandSide.MAIN_HAND ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND); return new BaseItemStack(ItemTypes.get(ForgeRegistries.ITEMS.getKey(is.getItem()).toString())); }
@EventHandler public void serverAboutToStart(FMLServerAboutToStartEvent event) { if (this.platform != null) { logger.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't"); WorldEdit.getInstance().getPlatformManager().unregister(platform); } this.platform = new ForgePlatform(this); WorldEdit.getInstance().getPlatformManager().register(platform); if (Loader.isModLoaded("sponge")) { this.provider = new ForgePermissionsProvider.SpongePermissionsProvider(); } else { this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform); } for (ResourceLocation name : Block.REGISTRY.getKeys()) { String nameStr = name.toString(); if (!BlockType.REGISTRY.keySet().contains(nameStr)) { BlockTypes.register(new BlockType(nameStr)); } } for (ResourceLocation name : Item.REGISTRY.getKeys()) { String nameStr = name.toString(); if (!ItemType.REGISTRY.keySet().contains(nameStr)) { ItemTypes.register(new ItemType(nameStr)); } } }
@Override public BlockState getBlock(BlockVector3 position) { World world = getWorld(); BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); IBlockState mcState = world.getBlockState(pos); BlockType blockType = BlockType.REGISTRY.get(Block.REGISTRY.getNameForObject(mcState.getBlock()).toString()); return blockType.getState(adaptProperties(blockType, mcState.getProperties())); }
/** Manual registration of a tool model. You probably shouldn't be using this. */ public static ResourceLocation registerToolModel(Item item, final ResourceLocation location) { if(!location.getResourcePath().endsWith(ToolModelLoader.EXTENSION)) { TConstruct.log.error("The material-model " + location.toString() + " does not end with '" + ToolModelLoader.EXTENSION + "' and will therefore not be loaded by the custom model loader!"); } return registerIt(item, location); }
public static String getTextureIdentifier(Item item) { String identifier = item.getRegistryName().toString(); // sanitize it (remove modid) if(identifier.contains(":")) { identifier = identifier.substring(identifier.lastIndexOf(':') + 1); } return "_" + identifier; } }
/** Manual registration of a material model. You probably shouldn't be using this. */ static ResourceLocation registerMaterialModel(Item item, final ResourceLocation location) { if(!location.getResourcePath().endsWith(MaterialModelLoader.EXTENSION)) { TConstruct.log.error("The material-model " + location.toString() + " does not end with '" + MaterialModelLoader.EXTENSION + "' and will therefore not be loaded by the custom model loader!"); } return registerIt(item, location); }
private static List<ResourceLocation> allOfGroup(ResourceLocation group) { String jsonGroup = group.toString(); return ForgeRegistries.RECIPES.getEntries().stream() .filter(e -> jsonGroup.equals(e.getValue().getGroup())) .map(Map.Entry::getKey) .collect(Collectors.toList()); } }
@Override public void writeToPacketNBT(NBTTagCompound cmp) { super.writeToPacketNBT(cmp); cmp.setString(TAG_LOOT_TABLE, lootTable.toString()); }
public static ItemStack setTagForPart(ItemStack stack, Item toolPart) { NBTTagCompound tag = TagUtil.getTagSafe(stack); tag.setString(TAG_PARTTYPE, toolPart.getRegistryName().toString()); stack.setTagCompound(tag); return stack; }
private boolean setBlock(ItemStack stack, Block block, int meta) { ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString()); ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); return true; }
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { if(SPAGHETTI_LOCATIONS.contains(event.getName().toString())) { event.getTable().addPool(pool); } } }
private static IBakedModel getTexturedModel(IBakedModel original, ResourceLocation location, Fluid fluid) { try { IModel model = ModelLoaderRegistry.getModel(location); IModel retextured = model.retexture(ImmutableMap.of("fluid", fluid.getStill().toString())); return retextured.bake(retextured.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); } catch(Exception e) { e.printStackTrace(); return original; } }
private boolean setBlock(ItemStack stack, Block block, int meta) { if(Item.getItemFromBlock(block) != Items.AIR) { ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString()); ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); return true; } return false; }
protected void addChiselVariation(Block block, int meta, String groupName) { if(block != null) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setString("group", groupName); nbt.setTag("stack", new ItemStack(block, 1, meta).writeToNBT(new NBTTagCompound())); nbt.setString("block", block.getRegistryName().toString()); nbt.setInteger("meta", meta); FMLInterModComms.sendMessage(modid, "add_variation", nbt); } } }
@Override public TextureAtlasSprite getTexture(ResourceLocation baseTexture, String location) { TextureAtlasSprite blockTexture = Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(texturePath.toString()); if(blockTexture == null) { blockTexture = TinkerTexture.loadManually(texturePath); } TextureColoredTexture sprite = new TextureColoredTexture(new ResourceLocation(blockTexture.getIconName()), baseTexture, location); sprite.stencil = false; return sprite; } }
private boolean setBlock(ItemStack stack, Block block, int meta) { if(Item.getItemFromBlock(block) != Items.AIR && (getBlock(stack) == null || getBlockCount(stack) == 0)) { ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, block.getRegistryName().toString()); ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); return true; } return false; }
@Override public void writePacketNBT(NBTTagCompound cmp) { if(camoState != null) { cmp.setString(TAG_CAMO, Block.REGISTRY.getNameForObject(camoState.getBlock()).toString()); cmp.setInteger(TAG_CAMO_META, camoState.getBlock().getMetaFromState(camoState)); } }
public static void putTexturedCuboid(BufferBuilder renderer, ResourceLocation location, double x1, double y1, double z1, double x2, double y2, double z2, int color, int brightness) { boolean flowing = false; TextureAtlasSprite sprite = mc.getTextureMapBlocks().getTextureExtry(location.toString()); putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness, flowing); putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness, flowing); putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness, flowing); putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness, flowing); putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness, flowing); putTexturedQuad(renderer, sprite, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness, flowing); }
public static void renderTiledFluid(int x, int y, int width, int height, float depth, FluidStack fluidStack) { TextureAtlasSprite fluidSprite = mc.getTextureMapBlocks().getAtlasSprite(fluidStack.getFluid().getStill(fluidStack).toString()); RenderUtil.setColorRGBA(fluidStack.getFluid().getColor(fluidStack)); renderTiledTextureAtlas(x, y, width, height, depth, fluidSprite, fluidStack.getFluid().isGaseous(fluidStack)); }
public void renderIcon(int par1, int par2, ResourceLocation loc, int par4, int par5, int brightness) { TextureAtlasSprite par3Icon = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(loc.toString()); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); //if(brightness != -1) //tessellator.getBuffer().putBrightness4(brightness, brightness, brightness, brightness); tessellator.getBuffer().pos(par1 + 0, par2 + par5, 0).tex(par3Icon.getMinU(), par3Icon.getMaxV()).endVertex(); tessellator.getBuffer().pos(par1 + par4, par2 + par5, 0).tex(par3Icon.getMaxU(), par3Icon.getMaxV()).endVertex(); tessellator.getBuffer().pos(par1 + par4, par2 + 0, 0).tex(par3Icon.getMaxU(), par3Icon.getMinV()).endVertex(); tessellator.getBuffer().pos(par1 + 0, par2 + 0, 0).tex(par3Icon.getMinU(), par3Icon.getMinV()).endVertex(); tessellator.draw(); }