use of net.minecraftforge.common.property.IExtendedBlockState in project Random-Things by lumien231.
the class ModelCustomWorkbench method getQuads.
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
checkDefault();
IBakedModel model = defaultModel;
IExtendedBlockState extendedState = (IExtendedBlockState) state;
IBlockState woodState = extendedState.getValue(BlockCustomWorkbench.WOOD_STATE);
if (woodState != null) {
if (modelCache.containsKey(woodState)) {
model = modelCache.get(woodState);
} else {
modelCache.put(woodState, new ModelCubeOverlay(RenderUtils.getQuadFaceMapFromState(woodState), overlays, Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(Blocks.PLANKS.getDefaultState()).getParticleTexture(), true));
model = modelCache.get(woodState);
}
}
return model.getQuads(woodState, side, rand);
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class BlockConveyor method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
state = super.getExtendedState(state, world, pos);
if (state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof TileEntityConveyorBelt))
return state;
state = ext.withProperty(ICONEYOR_PASSTHROUGH, ((TileEntityConveyorBelt) te).getConveyorSubtype());
}
return state;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class FeedthroughModel method getQuads.
@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
IBlockState baseState = Blocks.STONE.getDefaultState();
WireType wire = WireType.COPPER;
EnumFacing facing = EnumFacing.NORTH;
int offset = 1;
BlockPos p = null;
World w = null;
if (state instanceof IExtendedBlockState) {
TileEntity te = ((IExtendedBlockState) state).getValue(IEProperties.TILEENTITY_PASSTHROUGH);
if (te instanceof TileEntityFeedthrough) {
baseState = ((TileEntityFeedthrough) te).stateForMiddle;
wire = ((TileEntityFeedthrough) te).reference;
facing = ((TileEntityFeedthrough) te).getFacing();
offset = ((TileEntityFeedthrough) te).offset;
p = te.getPos();
w = te.getWorld();
}
}
final BlockPos pFinal = p;
final World wFinal = w;
FeedthroughCacheKey key = new FeedthroughCacheKey(wire, baseState, offset, facing, MinecraftForgeClient.getRenderLayer());
try {
return CACHE.get(key, () -> new SpecificFeedthroughModel(key, wFinal, pFinal)).getQuads(state, side, rand);
} catch (ExecutionException e) {
e.printStackTrace();
return ImmutableList.of();
}
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class IESmartObjModel method buildQuads.
private ImmutableList<BakedQuad> buildQuads() {
List<BakedQuad> quads = Lists.newArrayList();
ItemStack shader = ItemStack.EMPTY;
ShaderCase sCase = null;
IOBJModelCallback callback = null;
Object callbackObject = null;
if (!this.tempStack.isEmpty() && tempStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) {
ShaderWrapper wrapper = tempStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null);
if (wrapper != null) {
shader = wrapper.getShaderItem();
if (!shader.isEmpty() && shader.getItem() instanceof IShaderItem)
sCase = ((IShaderItem) shader.getItem()).getShaderCase(shader, tempStack, wrapper.getShaderType());
}
} else if (this.tempState != null && this.tempState instanceof IExtendedBlockState && ((IExtendedBlockState) this.tempState).getUnlistedNames().contains(CapabilityShader.BLOCKSTATE_PROPERTY)) {
ShaderWrapper wrapper = ((IExtendedBlockState) this.tempState).getValue(CapabilityShader.BLOCKSTATE_PROPERTY);
if (wrapper != null) {
shader = wrapper.getShaderItem();
if (!shader.isEmpty() && shader.getItem() instanceof IShaderItem)
sCase = ((IShaderItem) shader.getItem()).getShaderCase(shader, null, wrapper.getShaderType());
}
}
if (!this.tempStack.isEmpty() && tempStack.getItem() instanceof IOBJModelCallback) {
callback = (IOBJModelCallback) tempStack.getItem();
callbackObject = this.tempStack;
} else if (this.tempState != null && this.tempState instanceof IExtendedBlockState && ((IExtendedBlockState) this.tempState).getUnlistedNames().contains(IOBJModelCallback.PROPERTY)) {
callback = ((IExtendedBlockState) this.tempState).getValue(IOBJModelCallback.PROPERTY);
callbackObject = this.tempState;
}
for (String groupName : getModel().getMatLib().getGroups().keySet()) {
List<Pair<BakedQuad, ShaderLayer>> temp = addQuadsForGroup(callback, callbackObject, groupName, sCase, shader);
quads.addAll(temp.stream().filter(Objects::nonNull).map(Pair::getKey).collect(Collectors.toList()));
}
if (callback != null)
quads = callback.modifyQuads(callbackObject, quads);
return ImmutableList.copyOf(quads);
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class ModelConfigurableSides method getQuads.
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
TextureAtlasSprite[] tex = new TextureAtlasSprite[6];
for (int i = 0; i < tex.length; i++) tex[i] = this.textures[i][0];
char[] keyArray = "000000".toCharArray();
if (state instanceof IExtendedBlockState) {
IExtendedBlockState extended = (IExtendedBlockState) state;
for (int i = 0; i < IEProperties.SIDECONFIG.length; i++) if (extended.getUnlistedNames().contains(IEProperties.SIDECONFIG[i])) {
IEEnums.SideConfig config = extended.getValue(IEProperties.SIDECONFIG[i]);
if (config != null) {
int c = config.ordinal();
tex[i] = this.textures[i][c];
keyArray[i] = Character.forDigit(c, 10);
}
}
}
String key = name + String.copyValueOf(keyArray);
if (!modelCache.containsKey(key))
modelCache.put(key, bakeQuads(tex));
return modelCache.get(key);
}
Aggregations