use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.
the class MappingRegistry method read.
public void read(NBTTagCompound nbt) {
NBTTagList blocksMapping = nbt.getTagList("blocksMapping", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < blocksMapping.tagCount(); ++i) {
NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
if (!sub.hasKey("name")) {
// Keeping the order correct
idToBlock.add(null);
BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!");
continue;
}
String name = sub.getString("name");
ResourceLocation location = new ResourceLocation(name);
Block b = null;
if (!Block.REGISTRY.containsKey(location) && name.contains(":")) {
b = (Block) getMissingMappingFromFML(true, name, i);
if (b != null) {
BCLog.logger.info("Remapped " + name + " to " + Block.REGISTRY.getNameForObject(b));
}
}
if (b == null && Block.REGISTRY.containsKey(location)) {
b = (Block) Block.REGISTRY.getObject(location);
}
if (b != null) {
registerBlock(b);
} else {
// Keeping the order correct
idToBlock.add(null);
BCLog.logger.log(Level.WARN, "Can't load block " + name);
}
}
NBTTagList itemsMapping = nbt.getTagList("itemsMapping", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < itemsMapping.tagCount(); ++i) {
NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
if (!sub.hasKey("name")) {
// Keeping the order correct
idToItem.add(null);
BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!");
continue;
}
String name = sub.getString("name");
ResourceLocation location = new ResourceLocation(name);
Item item = null;
if (!Item.REGISTRY.containsKey(location) && name.contains(":")) {
item = (Item) getMissingMappingFromFML(false, name, i);
if (item != null) {
BCLog.logger.info("Remapped " + name + " to " + Item.REGISTRY.getNameForObject(item));
}
}
if (item == null && Item.REGISTRY.containsKey(location)) {
item = (Item) Item.REGISTRY.getObject(location);
}
if (item != null) {
registerItem(item);
} else {
// Keeping the order correct
idToItem.add(null);
BCLog.logger.log(Level.WARN, "Can't load item " + name);
}
}
NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < entitiesMapping.tagCount(); ++i) {
NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i);
String name = sub.getString("name");
Class<? extends Entity> e = null;
try {
e = (Class<? extends Entity>) Class.forName(name);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
if (e != null) {
registerEntity(e);
} else {
// Keeping the order correct
idToEntity.add(null);
BCLog.logger.log(Level.WARN, "Can't load entity " + name);
}
}
// System.out.println("[R] idToItem size : " + idToItem.size());
// for (Item i : idToItem) {
// System.out.println("- " + (i != null ? i.toString() : "null"));
// }
}
use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.
the class ClientProxy method initializeClient.
@Override
public void initializeClient() {
ModelLoaderRegistry.registerLoader(OutfittedTrackModel.Loader.INSTANCE);
ModelLoaderRegistry.registerLoader(OutfittedTrackItemModel.Loader.INSTANCE);
ModelLoaderRegistry.registerLoader(ActuatorModel.Loader.INSTANCE);
MinecraftForge.EVENT_BUS.register(RCSoundHandler.INSTANCE);
MinecraftForge.EVENT_BUS.register(JSONModelRenderer.INSTANCE);
MinecraftForge.EVENT_BUS.register(FluidModelRenderer.INSTANCE);
MinecraftForge.EVENT_BUS.register(GoggleAuraWorldRenderer.INSTANCE);
MinecraftForge.EVENT_BUS.register(new Object() {
@SubscribeEvent
public void textureStitch(TextureStitchEvent.Pre event) {
// CartContentRendererRedstoneFlux.instance().setRedstoneIcon(event.getMap().registerSprite(new ResourceLocation("railcraft:entities/carts/cart_redstone_flux")));
// CartContentRendererRedstoneFlux.instance().setFrameIcon(event.getMap().registerSprite(new ResourceLocation("railcraft:entities/carts/cart_redstone_flux_frame")));
ParticleSpark.sprite = event.getMap().registerSprite(new ResourceLocation("railcraft:particle/spark"));
ParticlePumpkin.sprite = event.getMap().registerSprite(new ResourceLocation("railcraft:particle/pumpkin"));
for (RailcraftBlocks blockContainer : RailcraftBlocks.VALUES) {
Block block = blockContainer.block();
if (block instanceof IRailcraftBlock) {
IRailcraftBlock railcraftBlock = (IRailcraftBlock) block;
railcraftBlock.registerTextures(event.getMap());
}
}
}
});
// Set<IRailcraftObjectContainer<IRailcraftItemSimple>> items = new HashSet<>();
// items.addAll(Arrays.asList(RailcraftItems.VALUES));
// items.addAll(Arrays.asList(RailcraftCarts.VALUES));
// for (IRailcraftObjectContainer<IRailcraftItemSimple> itemContainer : items) {
// itemContainer.getObject().ifPresent(IRailcraftItemSimple::initializeClient);
// }
RailcraftObjects.processItems(IRailcraftItemSimple::initializeClient);
// for (RailcraftBlocks blockContainer : RailcraftBlocks.VALUES) {
// ItemBlock item = blockContainer.item();
// blockContainer.getObject().ifPresent(block -> {
// block.initializeClient();
// if (item != null) {
// ((IRailcraftObject) item).initializeClient();
// IVariantEnum[] variants = block.getVariants();
// if (variants != null) {
// for (IVariantEnum variant : variants) {
// ItemStack stack = blockContainer.getStack(variant);
// if (stack != null)
// block.registerItemModel(stack, variant);
// }
// } else {
// ItemStack stack = blockContainer.getStack();
// if (stack != null)
// block.registerItemModel(stack, null);
// }
// }
// });
// }
RailcraftObjects.processBlocks((block, item) -> {
block.initializeClient();
if (item != null)
item.initializeClient();
}, (block, variant) -> {
ItemStack stack = block.getStack(variant);
if (stack != null)
block.registerItemModel(stack, variant);
});
JSONModelRenderer.INSTANCE.registerModel(CartContentRendererRedstoneFlux.CORE_MODEL);
JSONModelRenderer.INSTANCE.registerModel(CartContentRendererRedstoneFlux.FRAME_MODEL);
JSONModelRenderer.INSTANCE.registerModel(TESRManipulatorFluid.PIPE_MODEL);
RenderingRegistry.registerEntityRenderingHandler(EntityTunnelBore.class, RenderTunnelBore::new);
RenderingRegistry.registerEntityRenderingHandler(EntityMinecart.class, RenderCart::new);
}
use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.
the class ItemTrackOutfitted method initializeClient.
@SideOnly(Side.CLIENT)
@Override
public void initializeClient() {
ArrayList<ModelResourceLocation> textures = new ArrayList<>();
for (TrackType trackType : TrackRegistry.TRACK_TYPE) {
for (TrackKit trackKit : TrackRegistry.TRACK_KIT) {
textures.add(new ModelResourceLocation(new ResourceLocation(RailcraftConstants.RESOURCE_DOMAIN, MODEL_PREFIX + trackType.getName() + "." + trackKit.getName()), "inventory"));
}
}
ModelManager.registerComplexItemModel(this, (stack -> new ModelResourceLocation(new ResourceLocation(RailcraftConstants.RESOURCE_DOMAIN, MODEL_PREFIX + getSuffix(stack)), "inventory")), textures.toArray(new ModelResourceLocation[textures.size()]));
}
use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.
the class PipeDefinition_BC8 method registerSprites.
@SideOnly(Side.CLIENT)
public void registerSprites(TextureMap map) {
sprites = new TextureAtlasSprite[maxSprites];
for (int i = 0; i < spriteLocations.length; i++) {
String string = spriteLocations[i];
ResourceLocation location = new ResourceLocation(string);
sprites[i] = map.registerSprite(location);
}
}
use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.
the class TileTradeStation method readPacketData.
@Override
public void readPacketData(RailcraftInputStream data) throws IOException {
super.readPacketData(data);
profession = VillagerRegistry.instance().getRegistry().getValue(new ResourceLocation(data.readUTF()));
EnumFacing f = EnumFacing.getFront(data.readByte());
if (direction != f) {
direction = f;
markBlockForUpdate();
}
}
Aggregations