Merge pull request #2375 from bonii-xx/dynbucket

Default bucket model is empty, allow bucket model without fluid.
This commit is contained in:
Fry 2016-01-15 00:16:26 +03:00
commit dad870ea0b

View file

@ -48,7 +48,7 @@ public class ModelDynBucket implements IModel, IModelCustomData, IRetexturableMo
public ModelDynBucket() public ModelDynBucket()
{ {
this(null, null, null, FluidRegistry.WATER, false); this(null, null, null, null, false);
} }
public ModelDynBucket(ResourceLocation baseLocation, ResourceLocation liquidLocation, ResourceLocation coverLocation, Fluid fluid, boolean flipGas) public ModelDynBucket(ResourceLocation baseLocation, ResourceLocation liquidLocation, ResourceLocation coverLocation, Fluid fluid, boolean flipGas)
@ -88,22 +88,26 @@ public class ModelDynBucket implements IModel, IModelCustomData, IRetexturableMo
ImmutableMap<TransformType, TRSRTransformation> transformMap = IPerspectiveAwareModel.MapWrapper.getTransforms(state); ImmutableMap<TransformType, TRSRTransformation> transformMap = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
// if the fluid is a gas wi manipulate the initial state to be rotated 180° to turn it upside down // if the fluid is a gas wi manipulate the initial state to be rotated 180° to turn it upside down
if (flipGas && fluid.isGaseous()) if (flipGas && fluid != null && fluid.isGaseous())
{ {
state = new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(null, new Quat4f(0, 0, 1, 0), null, null))); state = new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(null, new Quat4f(0, 0, 1, 0), null, null)));
} }
TRSRTransformation transform = state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity()); TRSRTransformation transform = state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity());
TextureAtlasSprite fluidSprite = bakedTextureGetter.apply(fluid.getStill()); TextureAtlasSprite fluidSprite = null;
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
if(fluid != null) {
fluidSprite = bakedTextureGetter.apply(fluid.getStill());
}
if (baseLocation != null) if (baseLocation != null)
{ {
// build base (insidest) // build base (insidest)
IFlexibleBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter); IFlexibleBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter);
builder.addAll(model.getGeneralQuads()); builder.addAll(model.getGeneralQuads());
} }
if (liquidLocation != null) if (liquidLocation != null && fluidSprite != null)
{ {
TextureAtlasSprite liquid = bakedTextureGetter.apply(liquidLocation); TextureAtlasSprite liquid = bakedTextureGetter.apply(liquidLocation);
// build liquid layer (inside) // build liquid layer (inside)
@ -239,7 +243,10 @@ public class ModelDynBucket implements IModel, IModelCustomData, IRetexturableMo
// not a fluid item apparently // not a fluid item apparently
if (fluidStack == null) if (fluidStack == null)
{
// empty bucket
return this; return this;
}
Fluid fluid = fluidStack.getFluid(); Fluid fluid = fluidStack.getFluid();