Skip to content

Conversation

@iceiix
Copy link
Owner

@iceiix iceiix commented May 15, 2019

Add minimal support for a simple modded block

The chosen block to support: https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)

  • Forge handshake support and parsing (1.7.10: Forge handshake support #88 Add Forge handshake support (#88) #134 Forge 1.8.9-1.12.2 handshake protocol support #144)
  • Enhance steven_blocks macro to label block modid
  • Define a simple easily implementable modded block (ThermalExpansion:Rockwool)
  • Add modid lookup if id not in vanilla, split metadata
  • Link ModIdData/RegistryData to supported modded block modid lookup, removing hardcoded id
  • Test on 1.7.10 + forge 10.13.4.1614 + ThermalExpansion-[1.7.10]4.1.5-248
  • Test on 1.10.2 + FTB Beyond 1.11.0
  • Test on 1.12.2 + forge 1.12.2-14.23.5.2815 + CoFHCore-1.12.2-4.6.2.25 + CoFHWorld-1.12.2-1.3.0.6 + CodeChickenLib-1.12.2-3.2.2.353 + RedstoneFlux-1.12-2.1.0.6 + ThermalExpansion-1.12.2-5.5.3.41 + ThermalFoundation-1.12.2-2.6.2.26

@iceiix iceiix added the enhancement New feature or request label May 15, 2019
iceiix added 8 commits May 15, 2019 05:59
Fails due to Rust's mutability rules:

error[E0502]: cannot borrow `*self` as immutable because it is also borrowed as mutable
   --> src/world/mod.rs:626:44
    |
600 |                 self.chunks.get_mut(&cpos).unwrap()
    |                 ----------- mutable borrow occurs here
...
626 |                     section.blocks.set(bi, self.by_vanilla_id(id as usize));
    |                                            ^^^^ immutable borrow occurs here
...
635 |                         ) + (chunk.position.0 << 4, (i << 4) as i32, chunk.position.1 << 4);
    |                              ---------------- mutable borrow later used here
@iceiix iceiix changed the title [WIP] Modded block demo Modded block demo May 15, 2019
@iceiix
Copy link
Owner Author

iceiix commented May 15, 2019

This basically works, but the leading \u{2} byte on the block name seems wrong. Some other ids have \u{1}. Doesn't appear to be documented on https://wiki.vg/Minecraft_Forge_Handshake#ModIdData. What does this leading byte mean? Block vs item?

Not obvious from https://github.com/MinecraftForge/MinecraftForge/blob/1.7.10/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java#L153

        public void fromBytes(ByteBuf buffer)
        {
            int length = ByteBufUtils.readVarInt(buffer, 3);
            modIds = Maps.newHashMap();
            blockSubstitutions = Sets.newHashSet();
            itemSubstitutions = Sets.newHashSet();

            for (int i = 0; i < length; i++)
            {
                modIds.put(ByteBufUtils.readUTF8String(buffer),ByteBufUtils.readVarInt(buffer, 3));
            }

@iceiix
Copy link
Owner Author

iceiix commented May 15, 2019

There is a discriminator byte in https://github.com/MinecraftForge/MinecraftForge/blob/1.7.10/fml/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java#L340

            idMapping.put(discriminator+getNameForObject(thing), getId(thing));

The two discriminators are defined in https://github.com/MinecraftForge/MinecraftForge/blob/1.7.10/fml/src/main/java/cpw/mods/fml/common/registry/GameData.java#L763-L766

        iBlockRegistry = new FMLControlledNamespacedRegistry<Block>("minecraft:air", MAX_BLOCK_ID, MIN_BLOCK_ID, Block.class,'\u0001');
        iItemRegistry = new FMLControlledNamespacedRegistry<Item>(null, MAX_ITEM_ID, MIN_ITEM_ID, Item.class,'\u0002');

So, \u{1} = block, \u{2} = item.

@iceiix
Copy link
Owner Author

iceiix commented May 15, 2019

The 1.12.2 modpack tested in #148 doesn't have Thermal Expansion. Setting up a clean 1.12.2 server with the following (http://teamcofh.com/downloads/):

  • forge-1.12.2-14.23.5.2815-universal.jar
  • CoFHCore-1.12.2-4.6.2.25-universal.jar
  • CoFHWorld-1.12.2-1.3.0.6-universal.jar
  • CodeChickenLib-1.12.2-3.2.2.353-universal.jar
  • RedstoneFlux-1.12-2.1.0.6-universal.jar
  • ThermalExpansion-1.12.2-5.5.3.41-universal.jar
  • ThermalFoundation-1.12.2-2.6.2.26-universal.jar

Block name changed. Login and run command setblock -200 66 255 thermalfoundation:rockwool 1 on the server console.

@iceiix
Copy link
Owner Author

iceiix commented May 15, 2019

1.7.10:

Screen Shot 2019-05-15 at 10 48 26 AM

1.10.2:

Screen Shot 2019-05-15 at 10 52 09 AM

1.12.2:
Screen Shot 2019-05-15 at 10 36 07 AM

@iceiix iceiix merged commit 6fd4a12 into master May 15, 2019
@iceiix iceiix deleted the rockwool branch May 15, 2019 19:22
iceiix added a commit that referenced this pull request May 15, 2019
The first in support for modded content, a simple custom block: "rockwool" from the Thermal Expansion and Thermal Foundation mods for Forge:

https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)

This makes use of the Forge handshake (#88 #134 #144), matching the mod block names from the negotiation to numeric identifiers in the world to steven_blocks. Rockwool was chosen due to ease of implementation, it looks like wool from vanilla (except is fire-proof), and by supporting it the groundwork necessary is laid for more sophisticated mod support.

Tested with Thermal Expansion on 1.7.10, 1.10.2 (FTB Beyond), and 1.12.2 Forge servers.

* Add `modid` macro token, skipped from vanilla mappings

* Add ThermalExpansionRockwool block (1.7.10)

* Register modded blocks by modid->[data], and lookup block metadata

* Save block IDs from ModIdData/RegistryData to World modded_block_ids

* Add namespaced mod ids for ModIdData, \u{1}=block \u{2}=item

* Add ThermalFoundation's Rockwool (1.12.2)
@iceiix iceiix changed the title Modded block demo Modded block demo: Thermal Expansion's rockwool May 31, 2019
iceiix added a commit that referenced this pull request Feb 1, 2020
The first in support for modded content, a simple custom block: "rockwool" from the Thermal Expansion and Thermal Foundation mods for Forge:

https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)

This makes use of the Forge handshake (#88 #134 #144), matching the mod block names from the negotiation to numeric identifiers in the world to steven_blocks. Rockwool was chosen due to ease of implementation, it looks like wool from vanilla (except is fire-proof), and by supporting it the groundwork necessary is laid for more sophisticated mod support.

Tested with Thermal Expansion on 1.7.10, 1.10.2 (FTB Beyond), and 1.12.2 Forge servers.

* Add `modid` macro token, skipped from vanilla mappings

* Add ThermalExpansionRockwool block (1.7.10)

* Register modded blocks by modid->[data], and lookup block metadata

* Save block IDs from ModIdData/RegistryData to World modded_block_ids

* Add namespaced mod ids for ModIdData, \u{1}=block \u{2}=item

* Add ThermalFoundation's Rockwool (1.12.2)
iceiix added a commit that referenced this pull request Feb 1, 2020
The first in support for modded content, a simple custom block: "rockwool" from the Thermal Expansion and Thermal Foundation mods for Forge:

https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)

This makes use of the Forge handshake (#88 #134 #144), matching the mod block names from the negotiation to numeric identifiers in the world to steven_blocks. Rockwool was chosen due to ease of implementation, it looks like wool from vanilla (except is fire-proof), and by supporting it the groundwork necessary is laid for more sophisticated mod support.

Tested with Thermal Expansion on 1.7.10, 1.10.2 (FTB Beyond), and 1.12.2 Forge servers.

* Add `modid` macro token, skipped from vanilla mappings

* Add ThermalExpansionRockwool block (1.7.10)

* Register modded blocks by modid->[data], and lookup block metadata

* Save block IDs from ModIdData/RegistryData to World modded_block_ids

* Add namespaced mod ids for ModIdData, \u{1}=block \u{2}=item

* Add ThermalFoundation's Rockwool (1.12.2)
iceiix added a commit that referenced this pull request Feb 1, 2020
The first in support for modded content, a simple custom block: "rockwool" from the Thermal Expansion and Thermal Foundation mods for Forge:

https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)

This makes use of the Forge handshake (#88 #134 #144), matching the mod block names from the negotiation to numeric identifiers in the world to steven_blocks. Rockwool was chosen due to ease of implementation, it looks like wool from vanilla (except is fire-proof), and by supporting it the groundwork necessary is laid for more sophisticated mod support.

Tested with Thermal Expansion on 1.7.10, 1.10.2 (FTB Beyond), and 1.12.2 Forge servers.

* Add `modid` macro token, skipped from vanilla mappings

* Add ThermalExpansionRockwool block (1.7.10)

* Register modded blocks by modid->[data], and lookup block metadata

* Save block IDs from ModIdData/RegistryData to World modded_block_ids

* Add namespaced mod ids for ModIdData, \u{1}=block \u{2}=item

* Add ThermalFoundation's Rockwool (1.12.2)
iceiix added a commit that referenced this pull request Feb 2, 2020
The first in support for modded content, a simple custom block: "rockwool" from the Thermal Expansion and Thermal Foundation mods for Forge:

https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)

This makes use of the Forge handshake (#88 #134 #144), matching the mod block names from the negotiation to numeric identifiers in the world to steven_blocks. Rockwool was chosen due to ease of implementation, it looks like wool from vanilla (except is fire-proof), and by supporting it the groundwork necessary is laid for more sophisticated mod support.

Tested with Thermal Expansion on 1.7.10, 1.10.2 (FTB Beyond), and 1.12.2 Forge servers.

* Add `modid` macro token, skipped from vanilla mappings

* Add ThermalExpansionRockwool block (1.7.10)

* Register modded blocks by modid->[data], and lookup block metadata

* Save block IDs from ModIdData/RegistryData to World modded_block_ids

* Add namespaced mod ids for ModIdData, \u{1}=block \u{2}=item

* Add ThermalFoundation's Rockwool (1.12.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants