New Builder class in BlockStateContainer. Makes building containers with both listed and unlisted properties cleaner.

Make all methods of BiomeGenBase$BiomeProperties public so that modders can use that class outside subclasses.
This commit is contained in:
LexManos 2016-03-23 19:09:49 -07:00
parent 640670052c
commit 7e4d7077a5
2 changed files with 58 additions and 5 deletions

View File

@ -49,7 +49,7 @@
public Collection < IProperty<? >> func_177227_a()
{
return Collections. < IProperty<? >> unmodifiableCollection(this.field_177237_b.keySet());
@@ -414,5 +431,34 @@
@@ -414,5 +431,86 @@
{
return this.field_177239_a.func_185481_k(this);
}
@ -83,4 +83,56 @@
+ return this.field_177239_a.doesSideBlockRendering(this, world, pos, side);
+ }
}
+
+ /**
+ * Forge added class to make building things easier.
+ * Will return an instance of BlockStateContainer appropriate for
+ * the list of properties passed in.
+ *
+ * Example usage:
+ *
+ * protected BlockStateContainer createBlockState()
+ * {
+ * return (new BlockStateContainer.Builder(this)).add(FACING).add(SOME_UNLISTED).build();
+ * }
+ *
+ */
+ public static class Builder
+ {
+ private final Block block;
+ private final List<IProperty<?>> listed = Lists.newArrayList();
+ private final List<net.minecraftforge.common.property.IUnlistedProperty<?>> unlisted = Lists.newArrayList();
+
+ public Builder(Block block)
+ {
+ this.block = block;
+ }
+
+ public Builder add(IProperty<?>... props)
+ {
+ for (IProperty<?> prop : props)
+ this.listed.add(prop);
+ return this;
+ }
+
+ public Builder add(net.minecraftforge.common.property.IUnlistedProperty<?>... props)
+ {
+ for (net.minecraftforge.common.property.IUnlistedProperty<?> prop : props)
+ this.unlisted.add(prop);
+ return this;
+ }
+
+ public BlockStateContainer build()
+ {
+ IProperty<?>[] listed = new IProperty[this.listed.size()];
+ listed = this.listed.toArray(listed);
+ if (this.unlisted.size() == 0)
+ return new BlockStateContainer(this.block, listed);
+
+ net.minecraftforge.common.property.IUnlistedProperty<?>[] unlisted = new net.minecraftforge.common.property.IUnlistedProperty[this.unlisted.size()];
+ unlisted = this.unlisted.toArray(unlisted);
+
+ return new net.minecraftforge.common.property.ExtendedBlockState(this.block, listed, unlisted);
+ }
+ }
}

View File

@ -51,6 +51,7 @@ public net.minecraft.world.biome.BiomeGenPlains *()
public net.minecraft.world.biome.BiomeGenSavanna *()
public net.minecraft.world.biome.BiomeGenSnow *()
public net.minecraft.world.biome.BiomeGenTaiga *()
public net.minecraft.world.biome.BiomeGenBase$BiomeProperties *()
# Map Gen Biome Lists
public+f net.minecraft.world.gen.structure.MapGenStronghold field_151546_e
# MapGenVillage
@ -94,7 +95,7 @@ public net.minecraft.network.play.server.SPacketBlockChange field_148883_d # blo
public-f net.minecraft.world.WorldType field_77139_a #worldTypes
# DamageSource
public net.minecraft.util.DamageSource *() #All methods public, most are already
# EntityAITasks
# EntityAITasks
public net.minecraft.entity.ai.EntityAITasks field_75782_a # taskEntries
# EntityXPOrb
public net.minecraft.entity.item.EntityXPOrb field_70530_e # xpValue
@ -102,7 +103,7 @@ public net.minecraft.entity.item.EntityXPOrb field_70530_e # xpValue
public net.minecraft.world.gen.structure.StructureVillagePieces$Village
# RenderPlayer
public net.minecraft.client.renderer.entity.RenderBiped field_77071_a #modelBipedMain
# ChunkProviderServer
# ChunkProviderServer
public net.minecraft.world.gen.ChunkProviderServer field_186029_c # chunkGenerator
public net.minecraft.world.gen.ChunkProviderServer field_73244_f # loadedChunkHashMap
public net.minecraft.world.gen.ChunkProviderServer field_73245_g # loadedChunks
@ -159,7 +160,7 @@ public net.minecraft.client.renderer.VertexBuffer func_178972_a(IIIII)V # putCol
#public net.minecraft.client.renderer.block.model.ModelBlock <init>(Lnet/minecraft/util/ResourceLocation;Ljava/util/List;Ljava/util/Map;ZZLnet/minecraft/client/renderer/block/model/ItemCameraTransforms;)V
# RenderLivingEntity
#public net.minecraft.client.renderer.entity.RenderLivingBase func_177094_a(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # addLayer
# S00PacketServerInfo
public net.minecraft.network.status.server.SPacketServerInfo field_149297_a # GSON
@ -287,4 +288,4 @@ private-f net.minecraft.server.management.PlayerManager$PlayerInstance field_187
# RenderLivingBase
public net.minecraft.client.renderer.entity.RenderLivingBase func_177094_a(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # addLayer
public net.minecraft.client.renderer.entity.RenderLivingBase func_177089_b(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # removeLayer
public net.minecraft.client.renderer.entity.RenderLivingBase func_177089_b(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # removeLayer