use of mods.railcraft.api.tracks.TrackKit 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 mods.railcraft.api.tracks.TrackKit in project Railcraft by Railcraft.
the class ItemTrackOutfitted method placeBlockAt.
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
TrackKit trackKit = TrackRegistry.TRACK_KIT.get(stack);
newState = newState.withProperty(BlockTrackOutfitted.TICKING, trackKit.requiresTicks());
return super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
}
use of mods.railcraft.api.tracks.TrackKit in project Railcraft by Railcraft.
the class OutfittedTrackModel method getDependencies.
@Override
public Collection<ResourceLocation> getDependencies() {
if (trackTypeModelsLocations.isEmpty()) {
for (TrackType trackType : TrackRegistry.TRACK_TYPE) {
for (BlockRailBase.EnumRailDirection shape : BlockTrackOutfitted.SHAPE.getAllowedValues()) {
trackTypeModelsLocations.add(getTrackTypeModelLocation(trackType, shape));
}
}
}
if (trackKitModelsLocations.isEmpty()) {
TrackRegistry.TRACK_KIT.stream().filter(t -> t.getRenderer() == TrackKit.Renderer.COMPOSITE).forEach(t -> {
EnumSet<BlockRailBase.EnumRailDirection> shapes = EnumSet.copyOf(BlockTrackOutfitted.SHAPE.getAllowedValues());
if (!t.isAllowedOnSlopes()) {
shapes.removeIf(s -> !TrackShapeHelper.isLevelStraight(s));
}
for (BlockRailBase.EnumRailDirection shape : shapes) {
for (int state = 0; state < t.getRenderStates(); state++) trackKitModelsLocations.add(getTrackKitModelLocation(t, shape, state));
}
});
}
if (unifiedModelsLocations.isEmpty()) {
TrackRegistry.TRACK_KIT.stream().filter(t -> t.getRenderer() == TrackKit.Renderer.UNIFIED).forEach(trackKit -> {
EnumSet<BlockRailBase.EnumRailDirection> shapes = EnumSet.copyOf(BlockTrackOutfitted.SHAPE.getAllowedValues());
if (!trackKit.isAllowedOnSlopes()) {
shapes.removeIf(s -> !TrackShapeHelper.isLevelStraight(s));
}
for (TrackType trackType : TrackRegistry.TRACK_TYPE) for (BlockRailBase.EnumRailDirection shape : shapes) {
for (int state = 0; state < trackKit.getRenderStates(); state++) unifiedModelsLocations.add(getUnifiedModelLocation(trackType, trackKit, shape, state));
}
});
}
if (models.isEmpty()) {
models.addAll(trackTypeModelsLocations);
models.addAll(trackKitModelsLocations);
models.addAll(unifiedModelsLocations);
}
return models;
}
use of mods.railcraft.api.tracks.TrackKit in project Railcraft by Railcraft.
the class ItemTrackKit method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
playerIn.swingArm(hand);
if (Game.isClient(worldIn))
return EnumActionResult.PASS;
IBlockState oldState = WorldPlugin.getBlockState(worldIn, pos);
if (!TrackTools.isRailBlock(oldState)) {
return EnumActionResult.PASS;
}
TrackType trackType = null;
if (oldState.getBlock() instanceof BlockTrackFlex) {
BlockTrackFlex track = (BlockTrackFlex) oldState.getBlock();
trackType = track.getTrackType(worldIn, pos);
} else if (oldState.getBlock() == Blocks.RAIL) {
trackType = TrackTypes.IRON.getTrackType();
}
if (trackType != null) {
BlockRailBase.EnumRailDirection shape = TrackTools.getTrackDirectionRaw(worldIn, pos);
if (TrackShapeHelper.isStraight(shape)) {
TrackKit trackKit = TrackRegistry.TRACK_KIT.get(stack);
if (!shape.isAscending() || trackKit.isAllowedOnSlopes()) {
if (!trackKit.isAllowedTrackType(trackType)) {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.track_type");
return EnumActionResult.PASS;
}
if (BlockTrackOutfitted.placeTrack(worldIn, pos, playerIn, shape, trackType, trackKit)) {
SoundHelper.playPlaceSoundForBlock(worldIn, pos);
stack.stackSize--;
return EnumActionResult.SUCCESS;
}
} else {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.slope");
}
} else {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.curve");
}
} else {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.track");
}
return EnumActionResult.PASS;
}
Aggregations