net.minecraftforge.fml.common.FMLLog Java Examples

The following examples show how to use net.minecraftforge.fml.common.FMLLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InvokeWandMessage.java    From pycode-minecraft with MIT License 6 votes vote down vote up
private void handle(InvokeWandMessage message, MessageContext ctx) {
    // note: we only get send types BLOCK and ENTITY and we only handle this message on the server
    EntityPlayer player = ctx.getServerHandler().playerEntity;
    switch (message.typeOfHit) {
        case BLOCK:
            FMLLog.info("Got a InvokeWandMessage block=%s", message.blockPos);
            PythonWandItem.invokeOnBlock(player, message.blockPos);
        case ENTITY:
            // in theory this should never be invoked on the client...
            Entity entity = player.worldObj.getEntityByID(message.entityId);
            FMLLog.info("Got a InvokeWandMessage entity=%s", entity);
            if (entity == null) return;
            PythonWandItem.invokeOnEntity(player, entity);
            break;
        case MISS:
            PythonWandItem.invokeInDirection(player, message.hitVec);
    }
}
 
Example #2
Source File: PythonWandItem.java    From pycode-minecraft with MIT License 6 votes vote down vote up
@Nullable
static private PythonCode getCodeFromBook(EntityPlayer player) {
    ItemStack offhand = player.getHeldItemOffhand();
    if (offhand == null) {
        FMLLog.info("... nothing in off hand so pass");
        return null;
    }

    Item offitem = offhand.getItem();
    if (offitem instanceof PythonBookItem || offitem instanceof ItemWritableBook) {
        String content = PythonCode.bookAsString(offhand);
        if (content == null) {
            PythonCode.failz0r(player.worldObj, player.getPosition(), "Could not get pages from the book!?");
            return null;
        }

        PythonCode code = new PythonCode();
        code.setCodeString(content);

        // the following will actually run the code; TODO maybe setContext could be better-named?
        code.setContext(player.worldObj, player, player.getPosition());

        return code;
    }
    return null;
}
 
Example #3
Source File: HandEntity.java    From pycode-minecraft with MIT License 6 votes vote down vote up
public boolean handleItemInteraction(EntityPlayer player, ItemStack heldItem) {
    FMLLog.info("Hand Entity handleItemInteraction item=%s", heldItem);

    if (heldItem == null) {
        if (this.code.hasKey("run")) {
            this.code.put("hand", new HandMethods(this));
            this.code.setRunner(player);
            this.code.invoke("run", new MyEntityPlayer(player));
            this.code.setRunner(this);
        }
        return true;
    }

    Item item = heldItem.getItem();
    if (item instanceof PythonWandItem) {
        PythonWandItem.invokeOnEntity(player, this);
        return true;
    } else if (item instanceof PythonBookItem || item instanceof ItemWritableBook) {
        BlockPos pos = this.getPosition();
        this.code.put("hand", new HandMethods(this));
        this.code.setCodeFromBook(this.getEntityWorld(), player, this, pos, heldItem);
        return true;
    }
    FMLLog.info("... returning FALSE YEAH");
    return false;
}
 
Example #4
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 6 votes vote down vote up
/**
 * Load a new instance of HarvesterAnimationStateMachine at specified location,
 * with specified custom parameters.
 */
@SideOnly(Side.CLIENT)
public static HarvesterAnimationStateMachine load(IResourceManager manager, ResourceLocation location,
        ImmutableMap<String, ITimeValue> customParameters) {
    try (IResource resource = manager.getResource(location)) {
        ClipResolver clipResolver = new ClipResolver();
        ParameterResolver parameterResolver = new ParameterResolver(customParameters);
        Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver);
        TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver);
        HarvesterAnimationStateMachine asm = asmGson.fromJson(
                new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8),
                HarvesterAnimationStateMachine.class);
        clipResolver.asm = asm;
        parameterResolver.asm = asm;
        asm.initialize();

        return asm;
    } catch (IOException | JsonParseException e) {
        FMLLog.log.error("Exception loading Animation State Machine {}, skipping", location, e);
        return missing;
    } finally {
        Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null);
        TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null);
    }
}
 
Example #5
Source File: PythonCode.java    From pycode-minecraft with MIT License 6 votes vote down vote up
private void ensureCompiled() {
    if (!this.codeChanged) return;
    FMLLog.fine("Eval my code: %s", this.code);

    // now execute the code
    try {
        PythonEngine.eval(this.code, this.context);
        if (!world.isRemote) {
            ((WorldServer)world).spawnParticle(EnumParticleTypes.CRIT,
                    pos.getX() + .5, pos.getY() + 1, pos.getZ() + .5,
                    20, 0, 0, 0, .5, new int[0]);
        }
    } catch (ScriptException e) {
        failz0r(world, pos, "Error running code, traceback:\n%s", stackTraceToString(e));
    }
    this.codeChanged = false;
}
 
Example #6
Source File: Materials.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected static void registerMaterial(String name, MetalMaterial m){

		allMaterials.put(name, m);
		
		String enumName = m.getEnumName();
		String texName = m.getName();
		int[] protection = m.getDamageReductionArray();
		int durability = m.getArmorMaxDamageFactor();
		ArmorMaterial am = EnumHelper.addArmorMaterial(enumName, texName, durability, protection, m.getEnchantability(), SoundEvents.ITEM_ARMOR_EQUIP_IRON, (m.hardness > 10 ? (int)(m.hardness / 5) : 0));
		if(am == null){
			// uh-oh
			FMLLog.severe("Failed to create armor material enum for "+m);
		}
		armorMaterialMap.put(m, am);
		FMLLog.info("Created armor material enum "+am);
		
		ToolMaterial tm = EnumHelper.addToolMaterial(enumName, m.getToolHarvestLevel(), m.getToolDurability(), m.getToolEfficiency(), m.getBaseAttackDamage(), m.getEnchantability());
		if(tm == null){
			// uh-oh
			FMLLog.severe("Failed to create tool material enum for "+m);
		}
		toolMaterialMap.put(m, tm);
		FMLLog.info("Created tool material enum "+tm);
	}
 
Example #7
Source File: Items.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Uses reflection to expand the size of the combat damage and attack speed arrays to prevent initialization
 * index-out-of-bounds errors
 * @param itemClass The class to modify
 */
private static void expandCombatArrays(Class itemClass) throws IllegalAccessException, NoSuchFieldException {
    // WARNING: this method contains black magic
    final int expandedSize = 256;
    Field[] fields = itemClass.getDeclaredFields();
    for(Field f : fields){
        if(Modifier.isStatic(f.getModifiers())
                && f.getType().isArray()
                && f.getType().getComponentType().equals(float.class)){
            FMLLog.info("%s: Expanding array variable %s.%s to size %s", Thread.currentThread().getStackTrace()[0], itemClass.getSimpleName(), f.getName(), expandedSize);
            f.setAccessible(true); // bypass 'private' key word
            Field modifiersField = Field.class.getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL); // bypass 'final' key word
            float[] newArray = new float[expandedSize];
            Arrays.fill(newArray,0F);
            System.arraycopy(f.get(null),0,newArray,0, Array.getLength(f.get(null)));
            f.set(null,newArray);
        }
    }
}
 
Example #8
Source File: CrusherRecipeRegistry.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Adds a new crusher recipe (for the crack hammer and other rock crushers) 
 * where the input item is specified by an ItemStack. This means that only 
 * the specified item will be converted into the specified output item. 
 * @param input Item to be crushed
 * @param output The item to create as the result of this crusher recipe.
 */
public static void addNewCrusherRecipe(final ItemStack input, final ItemStack output){
	if(input == null || output == null) FMLLog.severe("%s: %s: Crusher recipe not registered because of null input or output. \n %s", 
			BaseMetals.MODID, CrusherRecipeRegistry.class,
			Arrays.toString(Thread.currentThread().getStackTrace()).replace(", ", "\n").replace("[", "").replace("]", "")
			);
	getInstance().addRecipe(new ArbitraryCrusherRecipe(input,output));
}
 
Example #9
Source File: PythonWandItem.java    From pycode-minecraft with MIT License 5 votes vote down vote up
public EnumActionResult onItemUse(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos,
                                  EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world == null || world.isRemote) return EnumActionResult.SUCCESS;
    FMLLog.info("Wand onItemUse stack=%s, hand=%s", itemstack, hand);
    invokeOnBlock(player, pos);
    return EnumActionResult.SUCCESS;
}
 
Example #10
Source File: PythonWandItem.java    From pycode-minecraft with MIT License 5 votes vote down vote up
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack itemstack, World world,
                                                EntityPlayer player, EnumHand hand) {
    FMLLog.info("Wand onItemRightClick stack=%s, hand=%s", itemstack, hand);
    if (world.isRemote) {
        // figure out what we're looking at and send it to the server
        RayTraceResult target = Minecraft.getMinecraft().objectMouseOver;
        ModNetwork.network.sendToServer(new InvokeWandMessage(target));
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, itemstack);
}
 
Example #11
Source File: PythonBookItem.java    From pycode-minecraft with MIT License 5 votes vote down vote up
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack itemstack, World world, EntityPlayer playerIn, EnumHand hand) {
    FMLLog.info("Book onItemRightClick stack=%s, hand=%s", itemstack, hand);
    // don't activate the GUI if in offhand; don't do *anything*
    if (hand == EnumHand.OFF_HAND) return new ActionResult(EnumActionResult.FAIL, itemstack);

    PyCode.proxy.openBook(playerIn, itemstack);
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
Example #12
Source File: BaseMetals.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Parses a String in the format (stack-size)*(modid):(item/block name)#(metadata value). The 
 * stacksize and metadata value parameters are optional.
 * @param str A String describing an itemstack (e.g. "4*minecraft:dye#15" or "minecraft:bow")
 * @param allowWildcard If true, then item strings that do not specify a metadata value will use 
 * the OreDictionary wildcard value. If false, then the default meta value is 0 instead.
 * @return An ItemStack representing the item, or null if the item is not found
 */
public static ItemStack parseStringAsItemStack(String str, boolean allowWildcard){
	str = str.trim();
	int count = 1;
	int meta;
	if(allowWildcard){
		meta = OreDictionary.WILDCARD_VALUE;
	} else {
		meta = 0;
	}
	int nameStart = 0;
	int nameEnd = str.length();
	if(str.contains("*")){
		count = Integer.parseInt(str.substring(0,str.indexOf("*")).trim());
		nameStart = str.indexOf("*")+1;
	}
	if(str.contains("#")){
		meta = Integer.parseInt(str.substring(str.indexOf("#")+1,str.length()).trim());
		nameEnd = str.indexOf("#");
	}
	String id = str.substring(nameStart,nameEnd).trim();
	if(Block.getBlockFromName(id) != null){
		// is a block
		return new ItemStack(Block.getBlockFromName(id),count,meta);
	} else if(Item.getByNameOrId(id) != null){
		// is an item
		return new ItemStack(Item.getByNameOrId(id),count,meta);
	} else {
		// item not found
		FMLLog.severe("Failed to find item or block for ID '"+id+"'");
		return null;
	}
}
 
Example #13
Source File: GuiTextArea.java    From pycode-minecraft with MIT License 5 votes vote down vote up
public void scrollBy(int amount) {
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        // TODO this reversal should probably be simplified??
        this.textXOffset -= amount;
    } else {
        this.textYOffset += amount;
    }
    FMLLog.info("text offset = %d, %d", textXOffset, textYOffset);
}
 
Example #14
Source File: ItemMetalArmor.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ItemMetalArmor createHelmet(MetalMaterial metal){
	ArmorMaterial material = cyano.basemetals.init.Materials.getArmorMaterialFor(metal);
	if(material == null){
		// uh-oh
		FMLLog.severe("Failed to load armor material enum for "+metal);
	}
	return new ItemMetalArmor(metal,material,material.ordinal(),EntityEquipmentSlot.HEAD);
}
 
Example #15
Source File: ItemMetalArmor.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ItemMetalArmor createChestplate(MetalMaterial metal){
	ArmorMaterial material = cyano.basemetals.init.Materials.getArmorMaterialFor(metal);
	if(material == null){
		// uh-oh
		FMLLog.severe("Failed to load armor material enum for "+metal);
	}
	return new ItemMetalArmor(metal,material,material.ordinal(),EntityEquipmentSlot.CHEST);
}
 
Example #16
Source File: ItemMetalArmor.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ItemMetalArmor createLeggings(MetalMaterial metal){
	ArmorMaterial material = cyano.basemetals.init.Materials.getArmorMaterialFor(metal);
	if(material == null){
		// uh-oh
		FMLLog.severe("Failed to load armor material enum for "+metal);
	}
	return new ItemMetalArmor(metal,material,material.ordinal(),EntityEquipmentSlot.LEGS);
}
 
Example #17
Source File: ItemMetalArmor.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ItemMetalArmor createBoots(MetalMaterial metal){
	ArmorMaterial material = cyano.basemetals.init.Materials.getArmorMaterialFor(metal);
	if(material == null){
		// uh-oh
		FMLLog.severe("Failed to load armor material enum for "+metal);
	}
	return new ItemMetalArmor(metal,material,material.ordinal(),EntityEquipmentSlot.FEET);
}
 
Example #18
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void tickStart(TickEvent.WorldTickEvent tick)
{
    World w = tick.world;
    if (!(w instanceof WorldServer))
    {
        return;
    }
    if (tick.phase == TickEvent.Phase.START)
    {
        counter = 0;
        getSemaphoreFor(w);
    }
    else
    {
        ListMultimap<ChunkPos, String> pending = pendingWork.get(w);
        if (pending == null)
        {
            return;
        }
        ImmutableList<Entry<ChunkPos, String>> forProcessing = ImmutableList.copyOf(Iterables.limit(pending.entries(), maxPerTick + 1));
        for (Entry<ChunkPos, String> entry : forProcessing)
        {
            if (counter++ > maxPerTick)
            {
                FMLLog.fine("Completed %d retrogens this tick. There are %d left for world %s", counter, pending.size(), w.getWorldInfo().getWorldName());
                return;
            }
            runRetrogen((WorldServer)w, entry.getKey(), entry.getValue());
        }
    }
}
 
Example #19
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
    FMLLog.fine("Passing generation for %s through to underlying generator", tag);
    delegate.generate(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
    ChunkPos chunkCoordIntPair = new ChunkPos(chunkX, chunkZ);
    completeRetrogen(chunkCoordIntPair, world, tag);
}
 
Example #20
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 5 votes vote down vote up
private void runRetrogen(WorldServer world, ChunkPos chunkCoords, String retroClass)
{
    long worldSeed = world.getSeed();
    Random fmlRandom = new Random(worldSeed);
    long xSeed = fmlRandom.nextLong() >> 2 + 1L;
    long zSeed = fmlRandom.nextLong() >> 2 + 1L;
    long chunkSeed = (xSeed * chunkCoords.chunkXPos + zSeed * chunkCoords.chunkZPos) ^ worldSeed;

    fmlRandom.setSeed(chunkSeed);
    ChunkProviderServer providerServer = world.getChunkProvider();
    IChunkGenerator generator = ObfuscationReflectionHelper.getPrivateValue(ChunkProviderServer.class, providerServer, "field_186029_c", "chunkGenerator");
    delegates.get(retroClass).delegate.generate(fmlRandom, chunkCoords.chunkXPos, chunkCoords.chunkZPos, world, generator, providerServer);
    FMLLog.fine("Retrogenerated chunk for %s", retroClass);
    completeRetrogen(chunkCoords, world, retroClass);
}
 
Example #21
Source File: ModLogger.java    From AgriCraft with MIT License 5 votes vote down vote up
public void log(Level logLevel, Object source, String format, Object... objects) {
    try {
        FMLLog.log(String.valueOf(source), logLevel, MessageFormat.format(format, objects));
    } catch (IllegalArgumentException ex) {
        // This is bad...
        FMLLog.log(String.valueOf(source), logLevel, format);
    }
}
 
Example #22
Source File: YUNoMakeGoodMap.java    From YUNoMakeGoodMap with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void load(FMLInitializationEvent event)
{
    FMLLog.log(Level.INFO, "YUNoMakeGoodMap Initalized");
    worldType = new VoidWorldType();

    DimensionManager.unregisterDimension(-1);
    DimensionManager.unregisterDimension(0);
    DimensionManager.unregisterDimension(1);
    DimensionManager.registerDimension(-1, DimensionType.register("Nether", "_nether", -1, WorldProviderHellVoid.class, false));
    DimensionManager.registerDimension(0,  DimensionType.register("Overworld", "", 0, WorldProviderSurfaceVoid.class, true));
    DimensionManager.registerDimension(1,  DimensionType.register("The End", "_end", 1, WorldProviderEndVoid.class, false));
}
 
Example #23
Source File: MixinLoadManager.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoad(String mixinPackage) {
    isSpongeEnabled = isSpongeEnabledSlow();
    if (isSpongeEnabled()) {
        FMLLog.bigWarning(
            "Valkyrien Skies has detected SpongeForge!");
    }
}
 
Example #24
Source File: ModTest.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void onPreInit(FMLPreInitializationEvent event)
{
    if (isLoaded)
    {
        FMLLog.log.info(messages[new Random().nextInt(messages.length)] + "...");
    }
}
 
Example #25
Source File: Chickenificator.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void onInit(FMLInitializationEvent event) {
	FMLLog.log.info("Chickenification is beginning...");
	//RenderingRegistry.registerEntityRenderingHandler(EntitySheep.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityCow.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityPig.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySquid.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityZombie.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySpider.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySkeleton.class, new RenderStupidChicken());
	FMLLog.log.info("Chickenificated all the bois!");
}
 
Example #26
Source File: TargetClassVisitor.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
   public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
       MethodVisitor visitor = super.visitMethod(access, name, desc, signature, exceptions);
       String methodKey = name + desc;
       if (this.methodKey.matches(name, desc)) {
           FMLLog.log("GTCETransformer", Level.INFO, "Patched method %s in %s successfully", methodKey, className);
           this.foundMethod = true;
           return visitorCreator.apply(visitor);
       }
       return visitor;
   }
 
Example #27
Source File: TargetClassVisitor.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
   public void visitEnd() {
       super.visitEnd();
       if (!foundMethod) {
       	FMLLog.log("ArmorRenderTransformer", Level.FATAL, "Failed to find method %s in %s.", methodKey, className);
           throw new RuntimeException("Failed to patch method " + methodKey + ", loading cannot continue. Check your environment is correct.");
       }
   }
 
Example #28
Source File: PyCodeBlockTileEntity.java    From pycode-minecraft with MIT License 5 votes vote down vote up
public boolean handleItemInteraction(EntityPlayer player, ItemStack heldItem) {
    FMLLog.info("Block Entity handleItemInteraction item=%s", heldItem);
    this.isPowered = this.worldObj.isBlockPowered(this.getPosition());

    if (heldItem == null) {
        // this is only ever invoked on the server
        if (this.code.hasKey("run")) {
            this.code.put("block", new BlockMethods(this));
            this.code.setContext(this.worldObj, player, this.getPosition() );
            this.code.invoke("run", new MyEntityPlayer(player));
            this.code.setRunner(this);
        }
        return true;
    }

    Item item = heldItem.getItem();
    if (item instanceof PythonWandItem) {
        PythonWandItem.invokeOnBlock(player, this.getPosition());
        return true;
    } else if (item instanceof PythonBookItem || item instanceof ItemWritableBook) {
        BlockPos pos = this.getPosition();
        this.code.put("block", new BlockMethods(this));
        this.code.setCodeFromBook(this.worldObj, player, this, pos, heldItem);
        return true;
    }

    return false;
}
 
Example #29
Source File: MixinLoadManager.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
    if (!isSpongeEnabled()) {
        if (mixinClassName.contains("spongepowered")) {
            FMLLog
                .bigWarning("Not applying" + mixinClassName + " because Sponge isn't loaded!");
            return false;
        }
    }

    return true;
}
 
Example #30
Source File: ValkyrienSkiesMod.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Mod.EventHandler
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
    if (MixinLoaderForge.isObfuscatedEnvironment) { //only print signature warning in obf
        FMLLog.bigWarning(
            "Valkyrien Skies JAR fingerprint corrupted, which means this copy of the mod "
                + "may have come from unofficial sources. Please check out our official website: "
                + "https://valkyrienskies.org");
    }
}