use of net.minecraft.block.properties.IProperty in project Tropicraft by Tropicraft.
the class WorldGenHomeTree method genVines.
public void genVines(int i, int j, int k) {
int length = rand.nextInt(15) + 8;
int dir = rand.nextInt(4);
IProperty direction = null;
if (dir == 0)
direction = BlockVine.NORTH;
if (dir == 1)
direction = BlockVine.SOUTH;
if (dir == 2)
direction = BlockVine.EAST;
if (dir == 3)
direction = BlockVine.WEST;
for (int y = j; y > j - length; y--) {
if (TCGenUtils.isAirBlock(worldObj, i, y, k)) {
placeBlock(i, y, k, Blocks.VINE.getDefaultState().withProperty(direction, Boolean.valueOf(true)), false);
} else
break;
}
}
use of net.minecraft.block.properties.IProperty in project EnderIO by SleepyTrousers.
the class ClientProxy method onModelRegistryEvent.
@SubscribeEvent
public static void onModelRegistryEvent(@Nonnull ModelRegistryEvent event) {
// Custom state mappers
EnderIOGlassesStateMapper.create();
ColdFireStateMapper.create();
LeverStateMapper.create();
final StateMap doorMapper = (new StateMap.Builder()).ignore(new IProperty[] { BlockDoor.POWERED }).build();
ModelLoader.setCustomStateMapper(ModObject.blockDarkSteelDoor.getBlockNN(), doorMapper);
ModelLoader.setCustomStateMapper(ModObject.blockPaintedDarkSteelDoor.getBlockNN(), doorMapper);
ModelLoader.setCustomStateMapper(ModObject.blockPaintedIronDoor.getBlockNN(), doorMapper);
ModelLoader.setCustomStateMapper(ModObject.blockPaintedWoodenDoor.getBlockNN(), doorMapper);
// Items of blocks that use smart rendering
SmartModelAttacher.registerBlockItemModels();
/*
* Most blocks register themselves with the SmartModelAttacher which will also handle their items. Those that don't need to implement IHaveRenderers and
* have their items handled here.
*
* Items that do _not_ belong to a block are handled here by either having the item implement IHaveRenderers or by registering the default renderer.
*/
for (IModObject mo : ModObjectRegistry.getObjects()) {
final Block block = mo.getBlock();
if (block instanceof ICustomSubItems) {
// NOP, handled by SmartModelAttacher
} else if (block instanceof IHaveRenderers) {
((IHaveRenderers) block).registerRenderers(mo);
} else if (block instanceof IDefaultRenderers) {
ClientUtil.registerDefaultItemRenderer(mo);
} else if (block == null || block == Blocks.AIR) {
final Item item = mo.getItem();
if (item instanceof ICustomSubItems) {
// NOP, handled by SmartModelAttacher
} else if (item instanceof IHaveRenderers) {
((IHaveRenderers) item).registerRenderers(mo);
} else if (item != null && item != Items.AIR) {
ClientUtil.registerDefaultItemRenderer(mo);
}
}
if (block instanceof IHaveTESR) {
((IHaveTESR) block).bindTileEntitySpecialRenderer();
}
}
}
use of net.minecraft.block.properties.IProperty in project EnderIO by SleepyTrousers.
the class SmartModelAttacher method bakeModels.
@SuppressWarnings({ "rawtypes", "unchecked" })
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void bakeModels(@Nonnull ModelBakeEvent event) {
for (RegistrationHolder holder : blocks) {
Block block = holder.block;
Map<IBlockState, ModelResourceLocation> locations = event.getModelManager().getBlockModelShapes().getBlockStateMapper().getVariants(block);
final IProperty holder_property = holder.property;
final Comparable holder_defaultsValue = holder.defaultsValue;
final IBakedModel missingModel = event.getModelManager().getMissingModel();
if (holder_property != null && block.getDefaultState().getPropertyKeys().contains(holder_property) && holder_defaultsValue != null) {
IBlockState defaultState = block.getDefaultState().withProperty(holder_property, holder_defaultsValue);
ModelResourceLocation defaultMrl = locations.get(defaultState);
if (defaultMrl == null) {
throw new RuntimeException("Model for state " + defaultState + " failed to load from " + defaultMrl + ". " + debugOutput(event.getModelRegistry(), defaultMrl, missingModel));
}
IBakedModel defaultBakedModel = event.getModelRegistry().getObject(defaultMrl);
if (defaultBakedModel == null) {
Log.warn("ModelBakeEvent: cannot register smart model over null model for " + holder.block + ". See model errors below.");
continue;
}
RelayingBakedModel model = new RelayingBakedModel(defaultBakedModel);
ModelResourceLocation itemMrl = new ModelResourceLocation(defaultMrl.getResourceDomain() + ":" + defaultMrl.getResourcePath() + "#inventory");
event.getModelRegistry().putObject(itemMrl, model);
if (defaultBakedModel == missingModel) {
// This is normal on the first pass. We register our synthetic models above anyway to avoid model loading errors.
continue;
}
for (Entry<IBlockState, ModelResourceLocation> entry : locations.entrySet()) {
final ModelResourceLocation entryMrl = NullHelper.notnullF(entry.getValue(), "BlockModelShapes contains null keys");
final IBlockState entryBlockstate = entry.getKey();
final IBakedModel existingModel = event.getModelRegistry().getObject(entryMrl);
if (existingModel == null || existingModel == missingModel) {
event.getModelRegistry().putObject(entryMrl, defaultBakedModel);
} else if (entryBlockstate.getValue(holder_property) == holder.autoValue) {
event.getModelRegistry().putObject(entryMrl, model);
}
}
} else {
IBlockState defaultState = block.getDefaultState();
ModelResourceLocation defaultMrl = locations.get(defaultState);
if (defaultMrl == null) {
throw new RuntimeException("Model for state " + defaultState + " failed to load from " + defaultMrl + ". " + debugOutput(event.getModelRegistry(), defaultMrl, missingModel));
}
IBakedModel defaultBakedModel = event.getModelRegistry().getObject(defaultMrl);
if (defaultBakedModel == null || defaultBakedModel == missingModel) {
continue;
}
if (!holder.itemOnly) {
for (ModelResourceLocation mrl0 : locations.values()) {
final ModelResourceLocation mrl = NullHelper.notnullF(mrl0, "BlockModelShapes contains null keys");
IBakedModel model = event.getModelRegistry().getObject(mrl);
if (model == null || model == missingModel) {
} else {
event.getModelRegistry().putObject(mrl, new RelayingBakedModel(NullHelper.first(model, defaultBakedModel)));
}
}
}
ModelResourceLocation itemMrl = new ModelResourceLocation(defaultMrl.getResourceDomain() + ":" + defaultMrl.getResourcePath() + "#inventory");
final IBakedModel model = event.getModelRegistry().getObject(itemMrl);
if (model == null || model == missingModel) {
event.getModelRegistry().putObject(itemMrl, new RelayingBakedModel(defaultBakedModel));
} else {
event.getModelRegistry().putObject(itemMrl, new RelayingBakedModel(model));
}
}
}
OverlayHolder.collectOverlayQuads(event);
}
use of net.minecraft.block.properties.IProperty in project ForestryMC by ForestryMC.
the class CropRubber method getReplantState.
/**
* Convert a "wet" rubber log blockstate into the dry version.
* Total hack since we don't have access to the blockstates.
*/
private static <T extends Comparable<T>> IBlockState getReplantState(IBlockState sappyState) {
if (hasRubberToHarvest(sappyState)) {
for (Map.Entry<IProperty<?>, Comparable<?>> wetPropertyEntry : sappyState.getProperties().entrySet()) {
String valueWetString = wetPropertyEntry.getValue().toString();
String valueDryString = valueWetString.replace("wet", "dry");
IProperty<?> property = wetPropertyEntry.getKey();
IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState();
IBlockState dryState = getStateWithValue(baseState, property, valueDryString);
if (dryState != null) {
return dryState;
}
}
}
return sappyState.getBlock().getDefaultState();
}
use of net.minecraft.block.properties.IProperty in project ForestryMC by ForestryMC.
the class WoodTypeStateMapper method getDefaultModelResourceLocation.
@Override
public ModelResourceLocation getDefaultModelResourceLocation(IBlockState state) {
final Map<IProperty<?>, Comparable<?>> properties;
if (propertyWoodType != null) {
properties = Maps.newLinkedHashMap(state.getProperties());
properties.remove(propertyWoodType);
} else {
properties = Maps.newLinkedHashMap(state.getProperties());
}
for (IProperty property : propertiesToRemove) {
properties.remove(property);
}
String resourceLocation = "arboriculture/" + blockPath;
String propertyString = this.getPropertyString(properties);
return new ModelResourceLocation(Constants.MOD_ID + ':' + resourceLocation, propertyString);
}
Aggregations