mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Merge branch '1.9.4'
This commit is contained in:
commit
caa61e1be9
332 files changed
+3806
-3131
No files matched your search
@@ -99,7 +99,7 @@ public class ClientCommandHandler extends CommandHandler
|
||||
private TextComponentTranslation format(TextFormatting color, String str, Object... args)
|
||||
{
|
||||
TextComponentTranslation ret = new TextComponentTranslation(str, args);
|
||||
ret.getChatStyle().setColor(color);
|
||||
ret.getStyle().setColor(color);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,35 +2,42 @@ package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.util.Util.EnumOS;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
import net.minecraft.client.settings.GameSettings.Options;
|
||||
import net.minecraft.client.settings.GameSettings.Options;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
public class EnumHelperClient extends EnumHelper
|
||||
{
|
||||
private static Class<?>[][] clientTypes =
|
||||
{
|
||||
{GameType.class, int.class, String.class},
|
||||
{GameType.class, int.class, String.class, String.class},
|
||||
{Options.class, String.class, boolean.class, boolean.class},
|
||||
{EnumOS.class}
|
||||
};
|
||||
|
||||
public static GameType addGameType(String name, int id, String displayName)
|
||||
|
||||
public static GameType addGameType(String name, int id, String displayName, String shortName)
|
||||
{
|
||||
return addEnum(GameType.class, name, id, displayName);
|
||||
return addEnum(GameType.class, name, id, displayName, shortName);
|
||||
}
|
||||
|
||||
|
||||
public static Options addOptions(String name, String langName, boolean isSlider, boolean isToggle)
|
||||
{
|
||||
return addEnum(Options.class, name, langName, isSlider, isToggle);
|
||||
}
|
||||
|
||||
|
||||
public static Options addOptions(String name, String langName, boolean isSlider, boolean isToggle, float valMin, float valMax, float valStep)
|
||||
{
|
||||
return addEnum(Options.class, name,
|
||||
new Class<?>[]{String.class, boolean.class, boolean.class, float.class, float.class, float.class},
|
||||
langName, isSlider, isToggle, valMin, valMax, valStep);
|
||||
}
|
||||
|
||||
public static EnumOS addOS2(String name)
|
||||
{
|
||||
return addEnum(EnumOS.class, name);
|
||||
}
|
||||
|
||||
public static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Object... paramValues)
|
||||
private static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Object... paramValues)
|
||||
{
|
||||
return addEnum(clientTypes, enumType, enumName, paramValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.BossInfoLerping;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||
import net.minecraftforge.client.event.FOVUpdateEvent;
|
||||
@@ -249,7 +249,7 @@ public class ForgeHooksClient
|
||||
for (int z = -distance; z <= distance; ++z)
|
||||
{
|
||||
BlockPos pos = center.add(x, 0, z);
|
||||
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
|
||||
Biome biome = world.getBiomeGenForCoords(pos);
|
||||
int colour = biome.getSkyColorByTemp(biome.getFloatTemperature(pos));
|
||||
r += (colour & 0xFF0000) >> 16;
|
||||
g += (colour & 0x00FF00) >> 8;
|
||||
|
||||
@@ -113,7 +113,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
if (renderHelmet) renderHelmet(res, partialTicks);
|
||||
|
||||
if (renderPortal && !mc.thePlayer.isPotionActive(MobEffects.confusion))
|
||||
if (renderPortal && !mc.thePlayer.isPotionActive(MobEffects.NAUSEA))
|
||||
{
|
||||
renderPortal(res, partialTicks);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
protected void renderCrosshairs(float partialTicks)
|
||||
{
|
||||
if (pre(CROSSHAIRS)) return;
|
||||
bind(Gui.icons);
|
||||
bind(Gui.ICONS);
|
||||
GlStateManager.enableBlend();
|
||||
super.renderAttackIndicator(partialTicks, res);
|
||||
post(CROSSHAIRS);
|
||||
@@ -217,7 +217,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
protected void renderBossHealth()
|
||||
{
|
||||
if (pre(BOSSHEALTH)) return;
|
||||
bind(Gui.icons);
|
||||
bind(Gui.ICONS);
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
mc.mcProfiler.startSection("bossHealth");
|
||||
GlStateManager.enableBlend();
|
||||
@@ -235,7 +235,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
if (this.mc.gameSettings.thirdPersonView == 0 && itemstack != null && itemstack.getItem() != null)
|
||||
{
|
||||
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
|
||||
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN))
|
||||
{
|
||||
renderPumpkinOverlay(res);
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
int left = width / 2 + 91;
|
||||
int top = height - right_height;
|
||||
|
||||
if (player.isInsideOfMaterial(Material.water))
|
||||
if (player.isInsideOfMaterial(Material.WATER))
|
||||
{
|
||||
int air = player.getAir();
|
||||
int full = MathHelper.ceiling_double_int((double)(air - 2) * 10.0D / 300.0D);
|
||||
@@ -341,7 +341,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
public void renderHealth(int width, int height)
|
||||
{
|
||||
bind(icons);
|
||||
bind(ICONS);
|
||||
if (pre(HEALTH)) return;
|
||||
mc.mcProfiler.startSection("health");
|
||||
GlStateManager.enableBlend();
|
||||
@@ -386,7 +386,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
if (rowHeight != 10) left_height += 10 - rowHeight;
|
||||
|
||||
int regen = -1;
|
||||
if (player.isPotionActive(MobEffects.regeneration))
|
||||
if (player.isPotionActive(MobEffects.REGENERATION))
|
||||
{
|
||||
regen = updateCounter % 25;
|
||||
}
|
||||
@@ -394,8 +394,8 @@ public class GuiIngameForge extends GuiIngame
|
||||
final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
|
||||
final int BACKGROUND = (highlight ? 25 : 16);
|
||||
int MARGIN = 16;
|
||||
if (player.isPotionActive(MobEffects.poison)) MARGIN += 36;
|
||||
else if (player.isPotionActive(MobEffects.wither)) MARGIN += 72;
|
||||
if (player.isPotionActive(MobEffects.POISON)) MARGIN += 36;
|
||||
else if (player.isPotionActive(MobEffects.WITHER)) MARGIN += 72;
|
||||
float absorbRemaining = absorb;
|
||||
|
||||
for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i)
|
||||
@@ -469,7 +469,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
int icon = 16;
|
||||
byte background = 0;
|
||||
|
||||
if (mc.thePlayer.isPotionActive(MobEffects.hunger))
|
||||
if (mc.thePlayer.isPotionActive(MobEffects.HUNGER))
|
||||
{
|
||||
icon += 36;
|
||||
background = 13;
|
||||
@@ -526,7 +526,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
protected void renderExperience(int width, int height)
|
||||
{
|
||||
bind(icons);
|
||||
bind(ICONS);
|
||||
if (pre(EXPERIENCE)) return;
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableBlend();
|
||||
@@ -577,7 +577,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
protected void renderJumpBar(int width, int height)
|
||||
{
|
||||
bind(icons);
|
||||
bind(ICONS);
|
||||
if (pre(JUMPBAR)) return;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableBlend();
|
||||
@@ -792,7 +792,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
protected void renderPlayerList(int width, int height)
|
||||
{
|
||||
ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().getObjectiveInDisplaySlot(0);
|
||||
NetHandlerPlayClient handler = mc.thePlayer.sendQueue;
|
||||
NetHandlerPlayClient handler = mc.thePlayer.connection;
|
||||
|
||||
if (mc.gameSettings.keyBindPlayerList.isKeyDown() && (!mc.isIntegratedServerRunning() || handler.getPlayerInfoMap().size() > 1 || scoreobjective != null))
|
||||
{
|
||||
@@ -813,7 +813,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
Entity tmp = player.getRidingEntity();
|
||||
if (!(tmp instanceof EntityLivingBase)) return;
|
||||
|
||||
bind(icons);
|
||||
bind(ICONS);
|
||||
|
||||
if (pre(HEALTHMOUNT)) return;
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ package net.minecraftforge.client;
|
||||
import java.util.BitSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.client.renderer.RegionRenderCache;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -68,24 +68,24 @@ public class MinecraftForgeClient
|
||||
}
|
||||
}
|
||||
|
||||
private static final LoadingCache<Pair<World, BlockPos>, RegionRenderCache> regionCache = CacheBuilder.newBuilder()
|
||||
private static final LoadingCache<Pair<World, BlockPos>, ChunkCache> regionCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(500)
|
||||
.concurrencyLevel(5)
|
||||
.expireAfterAccess(1, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<Pair<World, BlockPos>, RegionRenderCache>()
|
||||
.build(new CacheLoader<Pair<World, BlockPos>, ChunkCache>()
|
||||
{
|
||||
public RegionRenderCache load(Pair<World, BlockPos> key) throws Exception
|
||||
public ChunkCache load(Pair<World, BlockPos> key) throws Exception
|
||||
{
|
||||
return new RegionRenderCache(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1);
|
||||
return new ChunkCache(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1);
|
||||
}
|
||||
});
|
||||
|
||||
public static void onRebuildChunk(World world, BlockPos position, RegionRenderCache cache)
|
||||
public static void onRebuildChunk(World world, BlockPos position, ChunkCache cache)
|
||||
{
|
||||
regionCache.put(Pair.of(world, position), cache);
|
||||
}
|
||||
|
||||
public static RegionRenderCache getRegionRenderCache(World world, BlockPos pos)
|
||||
public static ChunkCache getRegionRenderCache(World world, BlockPos pos)
|
||||
{
|
||||
int x = pos.getX() & ~0xF;
|
||||
int y = pos.getY() & ~0xF;
|
||||
|
||||
@@ -44,7 +44,7 @@ import net.minecraft.client.renderer.block.model.multipart.Multipart;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Selector;
|
||||
import net.minecraft.client.renderer.block.statemap.BlockStateMapper;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.renderer.texture.IIconCreator;
|
||||
import net.minecraft.client.renderer.texture.ITextureMapPopulator;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
@@ -63,6 +63,7 @@ import net.minecraftforge.client.model.animation.ModelBlockAnimation;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.common.model.IModelPart;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.Models;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.common.model.animation.IClip;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
@@ -131,7 +132,7 @@ public final class ModelLoader extends ModelBakery
|
||||
textures.remove(TextureMap.LOCATION_MISSING_TEXTURE);
|
||||
textures.addAll(LOCATIONS_BUILTIN_TEXTURES);
|
||||
|
||||
textureMap.loadSprites(resourceManager, new IIconCreator()
|
||||
textureMap.loadSprites(resourceManager, new ITextureMapPopulator()
|
||||
{
|
||||
public void registerSprites(TextureMap map)
|
||||
{
|
||||
@@ -182,7 +183,7 @@ public final class ModelLoader extends ModelBakery
|
||||
@Override
|
||||
protected void loadBlocks()
|
||||
{
|
||||
List<Block> blocks = Lists.newArrayList(Iterables.filter(Block.blockRegistry, new Predicate<Block>()
|
||||
List<Block> blocks = Lists.newArrayList(Iterables.filter(Block.REGISTRY, new Predicate<Block>()
|
||||
{
|
||||
public boolean apply(Block block)
|
||||
{
|
||||
@@ -266,7 +267,7 @@ public final class ModelLoader extends ModelBakery
|
||||
|
||||
registerVariantNames();
|
||||
|
||||
List<Item> items = Lists.newArrayList(Iterables.filter(Item.itemRegistry, new Predicate<Item>()
|
||||
List<Item> items = Lists.newArrayList(Iterables.filter(Item.REGISTRY, new Predicate<Item>()
|
||||
{
|
||||
public boolean apply(Item item)
|
||||
{
|
||||
@@ -336,7 +337,7 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
|
||||
// empty bucket
|
||||
for(String s : getVariantNames(Items.bucket))
|
||||
for(String s : getVariantNames(Items.BUCKET))
|
||||
{
|
||||
ModelResourceLocation memory = getInventoryVariant(s);
|
||||
IModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation("forge", "item/bucket"));
|
||||
@@ -347,23 +348,23 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
}
|
||||
|
||||
setBucketModel(Items.water_bucket);
|
||||
setBucketModel(Items.lava_bucket);
|
||||
setBucketModel(Items.WATER_BUCKET);
|
||||
setBucketModel(Items.LAVA_BUCKET);
|
||||
// milk bucket only replaced if some mod adds milk
|
||||
if(FluidRegistry.isFluidRegistered("milk"))
|
||||
{
|
||||
// can the milk be put into a bucket?
|
||||
Fluid milk = FluidRegistry.getFluid("milk");
|
||||
FluidStack milkStack = new FluidStack(milk, FluidContainerRegistry.BUCKET_VOLUME);
|
||||
if(FluidContainerRegistry.getContainerCapacity(milkStack, new ItemStack(Items.bucket)) == FluidContainerRegistry.BUCKET_VOLUME)
|
||||
if(FluidContainerRegistry.getContainerCapacity(milkStack, new ItemStack(Items.BUCKET)) == FluidContainerRegistry.BUCKET_VOLUME)
|
||||
{
|
||||
setBucketModel(Items.milk_bucket);
|
||||
setBucketModel(Items.MILK_BUCKET);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// milk bucket if no milk fluid is present
|
||||
for(String s : getVariantNames(Items.milk_bucket))
|
||||
for(String s : getVariantNames(Items.MILK_BUCKET))
|
||||
{
|
||||
ModelResourceLocation memory = getInventoryVariant(s);
|
||||
IModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation("forge", "item/bucket_milk"));
|
||||
@@ -526,6 +527,10 @@ public final class ModelLoader extends ModelBakery
|
||||
SimpleBakedModel.Builder builder = (new SimpleBakedModel.Builder(model, model.createOverrides())).setTexture(particle);
|
||||
for(int i = 0; i < model.getElements().size(); i++)
|
||||
{
|
||||
if(modelState.apply(Optional.of(Models.getHiddenModelPart(ImmutableList.of(Integer.toString(i))))).isPresent())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BlockPart part = model.getElements().get(i);
|
||||
TRSRTransformation transformation = baseState;
|
||||
if(newTransforms.get(i) != null)
|
||||
|
||||
@@ -70,7 +70,7 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
||||
|
||||
lighter.setParent(new VertexBufferConsumer(VertexBuffer));
|
||||
lighter.setWorld(entity.worldObj);
|
||||
lighter.setState(Blocks.air.getDefaultState());
|
||||
lighter.setState(Blocks.AIR.getDefaultState());
|
||||
lighter.setBlockPos(pos);
|
||||
boolean empty = true;
|
||||
List<BakedQuad> quads = bakedModel.getQuads(null, null, 0);
|
||||
|
||||
@@ -19,7 +19,7 @@ public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRe
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer VertexBuffer = tessellator.getBuffer();
|
||||
this.bindTexture(TextureMap.locationBlocksTexture);
|
||||
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
@@ -47,6 +47,7 @@ import net.minecraftforge.client.model.b3d.B3DModel.Vertex;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.common.model.IModelPart;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.Models;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.common.model.animation.IClip;
|
||||
import net.minecraftforge.common.model.animation.IJoint;
|
||||
@@ -209,7 +210,14 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
|
||||
{
|
||||
// TODO make more use of Optional
|
||||
if(!part.isPresent()) return parent.apply(part);
|
||||
if(!part.isPresent())
|
||||
{
|
||||
if(parent != null)
|
||||
{
|
||||
return parent.apply(part);
|
||||
}
|
||||
return Optional.absent();
|
||||
}
|
||||
if(!(part.get() instanceof NodeJoint))
|
||||
{
|
||||
return Optional.absent();
|
||||
@@ -364,6 +372,10 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use AnimationProperty.
|
||||
*/
|
||||
@Deprecated
|
||||
public static enum B3DFrameProperty implements IUnlistedProperty<B3DState>
|
||||
{
|
||||
INSTANCE;
|
||||
@@ -679,26 +691,30 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
if(quads == null)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
generateQuads(builder, node, this.state);
|
||||
generateQuads(builder, node, this.state, ImmutableList.<String>of());
|
||||
quads = builder.build();
|
||||
}
|
||||
// TODO: caching?
|
||||
if(this.state != modelState)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
generateQuads(builder, node, modelState);
|
||||
generateQuads(builder, node, modelState, ImmutableList.<String>of());
|
||||
return builder.build();
|
||||
}
|
||||
return quads;
|
||||
}
|
||||
|
||||
private void generateQuads(ImmutableList.Builder<BakedQuad> builder, Node<?> node, final IModelState state)
|
||||
private void generateQuads(ImmutableList.Builder<BakedQuad> builder, Node<?> node, final IModelState state, ImmutableList<String> path)
|
||||
{
|
||||
ImmutableList.Builder<String> pathBuilder = ImmutableList.builder();
|
||||
pathBuilder.addAll(path);
|
||||
pathBuilder.add(node.getName());
|
||||
ImmutableList<String> newPath = pathBuilder.build();
|
||||
for(Node<?> child : node.getNodes().values())
|
||||
{
|
||||
generateQuads(builder, child, state);
|
||||
generateQuads(builder, child, state, newPath);
|
||||
}
|
||||
if(node.getKind() instanceof Mesh && meshes.contains(node.getName()))
|
||||
if(node.getKind() instanceof Mesh && meshes.contains(node.getName()) && !state.apply(Optional.of(Models.getHiddenModelPart(newPath))).isPresent())
|
||||
{
|
||||
Mesh mesh = (Mesh)node.getKind();
|
||||
Collection<Face> faces = mesh.bake(new Function<Node<?>, Matrix4f>()
|
||||
|
||||
@@ -32,16 +32,15 @@ import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.IModelCustomData;
|
||||
import net.minecraftforge.client.model.IPerspectiveAwareModel;
|
||||
import net.minecraftforge.client.model.IRetexturableModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.*;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.common.model.IModelPart;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.Models;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -1036,6 +1035,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static class Group implements IModelPart
|
||||
{
|
||||
public static final String DEFAULT_NAME = "OBJModel.Default.Element.Name";
|
||||
@@ -1092,6 +1092,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static class OBJState implements IModelState
|
||||
{
|
||||
protected Map<String, Boolean> visibilityMap = Maps.newHashMap();
|
||||
@@ -1230,6 +1231,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public enum OBJProperty implements IUnlistedProperty<OBJState>
|
||||
{
|
||||
INSTANCE;
|
||||
@@ -1262,7 +1264,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||
private final OBJModel model;
|
||||
private IModelState state;
|
||||
private final VertexFormat format;
|
||||
private Set<BakedQuad> quads;
|
||||
private ImmutableList<BakedQuad> quads;
|
||||
private ImmutableMap<String, TextureAtlasSprite> textures;
|
||||
private TextureAtlasSprite sprite = ModelLoader.White.INSTANCE;
|
||||
|
||||
@@ -1277,98 +1279,122 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||
|
||||
public void scheduleRebake()
|
||||
{
|
||||
this.quads = null;
|
||||
}
|
||||
|
||||
// FIXME: merge with getQuads
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
|
||||
{
|
||||
if(side != null) return ImmutableList.of();
|
||||
if (side != null) return ImmutableList.of();
|
||||
if (quads == null)
|
||||
{
|
||||
quads = Collections.synchronizedSet(new LinkedHashSet<BakedQuad>());
|
||||
Set<Face> faces = Collections.synchronizedSet(new LinkedHashSet<Face>());
|
||||
Optional<TRSRTransformation> transform = Optional.absent();
|
||||
for (Group g : this.model.getMatLib().getGroups().values())
|
||||
quads = buildQuads(this.state);
|
||||
}
|
||||
if (blockState instanceof IExtendedBlockState)
|
||||
{
|
||||
IExtendedBlockState exState = (IExtendedBlockState) blockState;
|
||||
if (exState.getUnlistedNames().contains(Properties.AnimationProperty))
|
||||
{
|
||||
// g.minUVBounds = this.model.getMatLib().minUVBounds;
|
||||
// g.maxUVBounds = this.model.getMatLib().maxUVBounds;
|
||||
// FMLLog.info("Group: %s u: [%f, %f] v: [%f, %f]", g.name, g.minUVBounds[0], g.maxUVBounds[0], g.minUVBounds[1], g.maxUVBounds[1]);
|
||||
|
||||
if (this.state instanceof OBJState)
|
||||
IModelState newState = exState.getValue(Properties.AnimationProperty);
|
||||
if (newState != null)
|
||||
{
|
||||
OBJState state = (OBJState) this.state;
|
||||
if (state.parent != null)
|
||||
newState = new ModelStateComposition(this.state, newState);
|
||||
return buildQuads(newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
return quads;
|
||||
}
|
||||
|
||||
private ImmutableList<BakedQuad> buildQuads(IModelState modelState)
|
||||
{
|
||||
List<BakedQuad> quads = Lists.newArrayList();
|
||||
Collections.synchronizedSet(new LinkedHashSet<BakedQuad>());
|
||||
Set<Face> faces = Collections.synchronizedSet(new LinkedHashSet<Face>());
|
||||
Optional<TRSRTransformation> transform = Optional.absent();
|
||||
for (Group g : this.model.getMatLib().getGroups().values())
|
||||
{
|
||||
// g.minUVBounds = this.model.getMatLib().minUVBounds;
|
||||
// g.maxUVBounds = this.model.getMatLib().maxUVBounds;
|
||||
// FMLLog.info("Group: %s u: [%f, %f] v: [%f, %f]", g.name, g.minUVBounds[0], g.maxUVBounds[0], g.minUVBounds[1], g.maxUVBounds[1]);
|
||||
|
||||
if(modelState.apply(Optional.of(Models.getHiddenModelPart(ImmutableList.of(g.getName())))).isPresent())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (modelState instanceof OBJState)
|
||||
{
|
||||
OBJState state = (OBJState) modelState;
|
||||
if (state.parent != null)
|
||||
{
|
||||
transform = state.parent.apply(Optional.<IModelPart>absent());
|
||||
}
|
||||
//TODO: can this be replaced by updateStateVisibilityMap(OBJState)?
|
||||
if (state.getGroupNamesFromMap().contains(Group.ALL))
|
||||
{
|
||||
state.visibilityMap.clear();
|
||||
for (String s : this.model.getMatLib().getGroups().keySet())
|
||||
{
|
||||
transform = state.parent.apply(Optional.<IModelPart>absent());
|
||||
state.visibilityMap.put(s, state.operation.performOperation(true));
|
||||
}
|
||||
//TODO: can this be replaced by updateStateVisibilityMap(OBJState)?
|
||||
if (state.getGroupNamesFromMap().contains(Group.ALL))
|
||||
}
|
||||
else if (state.getGroupNamesFromMap().contains(Group.ALL_EXCEPT))
|
||||
{
|
||||
List<String> exceptList = state.getGroupNamesFromMap().subList(1, state.getGroupNamesFromMap().size());
|
||||
state.visibilityMap.clear();
|
||||
for (String s : this.model.getMatLib().getGroups().keySet())
|
||||
{
|
||||
state.visibilityMap.clear();
|
||||
for (String s : this.model.getMatLib().getGroups().keySet())
|
||||
if (!exceptList.contains(s))
|
||||
{
|
||||
state.visibilityMap.put(s, state.operation.performOperation(true));
|
||||
}
|
||||
}
|
||||
else if (state.getGroupNamesFromMap().contains(Group.ALL_EXCEPT))
|
||||
{
|
||||
List<String> exceptList = state.getGroupNamesFromMap().subList(1, state.getGroupNamesFromMap().size());
|
||||
state.visibilityMap.clear();
|
||||
for (String s : this.model.getMatLib().getGroups().keySet())
|
||||
{
|
||||
if (!exceptList.contains(s))
|
||||
{
|
||||
state.visibilityMap.put(s, state.operation.performOperation(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String s : state.visibilityMap.keySet())
|
||||
{
|
||||
state.visibilityMap.put(s, state.operation.performOperation(state.visibilityMap.get(s)));
|
||||
}
|
||||
}
|
||||
if (state.getGroupsWithVisibility(true).contains(g.getName()))
|
||||
{
|
||||
faces.addAll(g.applyTransform(transform));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transform = state.apply(Optional.<IModelPart>absent());
|
||||
for (String s : state.visibilityMap.keySet())
|
||||
{
|
||||
state.visibilityMap.put(s, state.operation.performOperation(state.visibilityMap.get(s)));
|
||||
}
|
||||
}
|
||||
if (state.getGroupsWithVisibility(true).contains(g.getName()))
|
||||
{
|
||||
faces.addAll(g.applyTransform(transform));
|
||||
}
|
||||
}
|
||||
for (Face f : faces)
|
||||
else
|
||||
{
|
||||
if (this.model.getMatLib().materials.get(f.getMaterialName()).isWhite())
|
||||
{
|
||||
for (Vertex v : f.getVertices())
|
||||
{//update material in each vertex
|
||||
if (!v.getMaterial().equals(this.model.getMatLib().getMaterial(v.getMaterial().getName())))
|
||||
{
|
||||
v.setMaterial(this.model.getMatLib().getMaterial(v.getMaterial().getName()));
|
||||
}
|
||||
}
|
||||
sprite = ModelLoader.White.INSTANCE;
|
||||
} else sprite = this.textures.get(f.getMaterialName());
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
|
||||
builder.setContractUVs(true);
|
||||
builder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z));
|
||||
builder.setTexture(sprite);
|
||||
Normal faceNormal = f.getNormal();
|
||||
putVertexData(builder, f.verts[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], sprite);
|
||||
putVertexData(builder, f.verts[1], faceNormal, TextureCoordinate.getDefaultUVs()[1], sprite);
|
||||
putVertexData(builder, f.verts[2], faceNormal, TextureCoordinate.getDefaultUVs()[2], sprite);
|
||||
putVertexData(builder, f.verts[3], faceNormal, TextureCoordinate.getDefaultUVs()[3], sprite);
|
||||
quads.add(builder.build());
|
||||
transform = modelState.apply(Optional.<IModelPart>absent());
|
||||
faces.addAll(g.applyTransform(transform));
|
||||
}
|
||||
}
|
||||
List<BakedQuad> quadList = Collections.synchronizedList(Lists.newArrayList(quads));
|
||||
return quadList;
|
||||
for (Face f : faces)
|
||||
{
|
||||
if (this.model.getMatLib().materials.get(f.getMaterialName()).isWhite())
|
||||
{
|
||||
for (Vertex v : f.getVertices())
|
||||
{//update material in each vertex
|
||||
if (!v.getMaterial().equals(this.model.getMatLib().getMaterial(v.getMaterial().getName())))
|
||||
{
|
||||
v.setMaterial(this.model.getMatLib().getMaterial(v.getMaterial().getName()));
|
||||
}
|
||||
}
|
||||
sprite = ModelLoader.White.INSTANCE;
|
||||
}
|
||||
else sprite = this.textures.get(f.getMaterialName());
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
|
||||
builder.setContractUVs(true);
|
||||
builder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z));
|
||||
builder.setTexture(sprite);
|
||||
Normal faceNormal = f.getNormal();
|
||||
putVertexData(builder, f.verts[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], sprite);
|
||||
putVertexData(builder, f.verts[1], faceNormal, TextureCoordinate.getDefaultUVs()[1], sprite);
|
||||
putVertexData(builder, f.verts[2], faceNormal, TextureCoordinate.getDefaultUVs()[2], sprite);
|
||||
putVertexData(builder, f.verts[3], faceNormal, TextureCoordinate.getDefaultUVs()[3], sprite);
|
||||
quads.add(builder.build());
|
||||
}
|
||||
return ImmutableList.copyOf(quads);
|
||||
}
|
||||
|
||||
private final void putVertexData(UnpackedBakedQuad.Builder builder, Vertex v, Normal faceNormal, TextureCoordinate defUV, TextureAtlasSprite sprite)
|
||||
|
||||
@@ -11,7 +11,7 @@ public enum KeyModifier {
|
||||
@Override
|
||||
public boolean matches(int keyCode)
|
||||
{
|
||||
if (Minecraft.isRunningOnMac)
|
||||
if (Minecraft.IS_RUNNING_ON_MAC)
|
||||
{
|
||||
return keyCode == Keyboard.KEY_LMETA || keyCode == Keyboard.KEY_RMETA;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public enum KeyModifier {
|
||||
public String getLocalizedComboName(int keyCode)
|
||||
{
|
||||
String keyName = GameSettings.getKeyDisplayString(keyCode);
|
||||
String localizationFormatKey = Minecraft.isRunningOnMac ? "forge.controlsgui.control.mac" : "forge.controlsgui.control";
|
||||
String localizationFormatKey = Minecraft.IS_RUNNING_ON_MAC ? "forge.controlsgui.control.mac" : "forge.controlsgui.control";
|
||||
return I18n.format(localizationFormatKey, keyName);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user