Java Code Examples for net.minecraftforge.fml.common.FMLLog#info()

The following examples show how to use net.minecraftforge.fml.common.FMLLog#info() . 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: 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 2
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 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: 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 5
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 6
Source File: PyRegistry.java    From pycode-minecraft with MIT License 5 votes vote down vote up
public static Block getBlock(String blockName) throws BlockTypeError {
    Block block = Block.REGISTRY.getObject(new ResourceLocation(blockName));
    FMLLog.info("getBlock asked for '%s', got '%s'", blockName, block.getUnlocalizedName());
    if (block.getUnlocalizedName().equals("tile.air") && !blockName.equals("air")) {
        throw new BlockTypeError(blockName);
    }
    return block;
}
 
Example 7
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 8
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 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: 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 11
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 12
Source File: PythonBlock.java    From pycode-minecraft with MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand,
                                @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    FMLLog.info("onBlockActivated item=%s", heldItem);
    PyCodeBlockTileEntity code_block = this.getEntity(world, pos);
    return code_block == null || code_block.handleItemInteraction(playerIn, heldItem);
}
 
Example 13
Source File: BaseMethods.java    From pycode-minecraft with MIT License 5 votes vote down vote up
protected void put(BlockPos pos, IBlockState block_state, EnumFacing facing) {
    // don't run on client
    if (this.world == null || this.world.isRemote) return;

    Block block = block_state.getBlock();

    FMLLog.info("Putting %s at %s", block_state, pos);

    // handle special cases
    if (block instanceof BlockDoor) {
        ItemDoor.placeDoor(this.world, pos, facing, block, true);
    } else if (block instanceof BlockBed) {
        BlockPos headpos = pos.offset(facing);
        if (this.world.getBlockState(pos.down()).isSideSolid(this.world, pos.down(), EnumFacing.UP) &&
                this.world.getBlockState(headpos.down()).isSideSolid(this.world, headpos.down(), EnumFacing.UP)) {
            block_state = block_state
                    .withProperty(BlockBed.OCCUPIED, false).withProperty(BlockBed.FACING, facing)
                    .withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);
            if (this.world.setBlockState(pos, block_state, 11)) {
                block_state = block_state.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD);
                this.world.setBlockState(headpos, block_state, 11);
            }
        }
    } else {
        this.world.setBlockState(pos, block_state);
    }
}
 
Example 14
Source File: PythonWandItem.java    From pycode-minecraft with MIT License 4 votes vote down vote up
static public void invokeOnEntity(EntityPlayer player, Entity entity) {
    FMLLog.info("Wand invokeOnEntity%s, entity=%s", player, entity);
    PythonCode code = getCodeFromBook(player);
    if (code == null) return ;
    if (code.hasKey("invoke")) code.invoke("invoke", PyRegistry.myWrapper(player.worldObj, entity));
}
 
Example 15
Source File: MyEntity.java    From pycode-minecraft with MIT License 4 votes vote down vote up
public void ignite(int seconds) {
    // ignite as if immersed in lava
    FMLLog.info("FIRE??? %s", this.entity);
    this.entity.setFire(4);
}
 
Example 16
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent evt)
{
    this.pendingWork = new MapMaker().weakKeys().makeMap();
    this.completedWork = new MapMaker().weakKeys().makeMap();
    this.completedWorkLocks = new MapMaker().weakKeys().makeMap();

    Set<IWorldGenerator> worldGens = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGenerators");
    Map<IWorldGenerator,Integer> worldGenIdx = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGeneratorIndex");

    for (String retro : ImmutableSet.copyOf(retros.keySet()))
    {
        if (!delegates.containsKey(retro))
        {
            FMLLog.info("Substituting worldgenerator %s with delegate", retro);
            for (Iterator<IWorldGenerator> iterator = worldGens.iterator(); iterator.hasNext();)
            {
                IWorldGenerator wg = iterator.next();
                if (wg.getClass().getName().equals(retro))
                {
                    iterator.remove();
                    TargetWorldWrapper tww = new TargetWorldWrapper();
                    tww.delegate = wg;
                    tww.tag = retro;
                    worldGens.add(tww);
                    Integer idx = worldGenIdx.remove(wg);
                    worldGenIdx.put(tww, idx);
                    FMLLog.info("Successfully substituted %s with delegate", retro);
                    delegates.put(retro, tww);
                    break;
                }
            }

            if (!delegates.containsKey(retro))
            {
                FMLLog.warning("WorldRetrogen was not able to locate world generator class %s, it will be skipped, found %s", retro, worldGens);
                retros.remove(retro);
            }
        }
    }
}
 
Example 17
Source File: VoidWorldBiomeProvider.java    From YUNoMakeGoodMap with Apache License 2.0 4 votes vote down vote up
private void buildSpawn(World world, BlockPos pos)
{
    FMLLog.info("[YUNoMakeGoodMap] Building spawn platform at: %d, %d, %d", pos.getX(), pos.getY(), pos.getZ());
    IPlatformGenerator platform = YUNoMakeGoodMap.instance.getPlatformType(world);
    platform.generate(world, pos);
}